I am using C#. Below is my sample code.
private void Page_Load(object sender, System.EventArgs e)
{
string str = Request.UrlReferrer.ToString();
Label1.Text = str;
}
The result in Label1.Text is http://localhost:82/data/WebForm1.aspx.
Now I want the result “WebForm1.aspx” in Label1.Text
can you please help me?
Thanks.
If you want only the part after the last
/in the URL, calling theSystem.IO.Path.GetFileName()method on theUri.LocalPathshould do the trick:If you want the output to keep query string information from the URI, use the
PathAndQueryproperty: