Question

In VS2003, I am trying to find out the particular page where the request is coming from. I want to identify the exact aspx page name.

Is there a way to only get the page name or some how strip the page name?

Currently I am using the following instruction...

string referencepage = HttpContext.Current.Request.UrlReferrer.ToString();

and I get the following result...

"http://localhost/MyPage123.aspx?myval1=3333&myval2=4444;

I want to get the result back with out any query string parameters and be able to identify the page MyPage123.aspx accurately...

How do I do that??

Was it helpful?

Solution

Look at the Segments property of the URI class (which is what HttpContext.Current.Request.UrlReferrer returns).

Something like HttpContext.Current.Request.UrlReferrer.Segments[1] (changing the 1 indexer to get the correct segment you require).

OTHER TIPS

Instead of calling .ToString on the Uri, use the AbsolutePath property instead:

string referencepage = HttpContext.Current.Request.UrlReferrer.AbsolutePath;

This should get you "/MyPage123.aspx" in your case.

Edit: Had LocalPath instead of AbsolutePath by mistake

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top