How to define referrer page in ASP.NET?

In VS2003, I am trying to find the specific page where the request is coming from. I want to determine the exact name of the aspx page.

Is there any way to get the page name or some way to remove the page name?

I am currently 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 with any query string parameters and be able to accurately identify the MyPage123.aspx page ...

How should I do it?

+3
source share
2 answers

Segments URI ( , HttpContext.Current.Request.UrlReferrer).

- HttpContext.Current.Request.UrlReferrer.Segments[1] ( 1, ).

+5

.ToString Uri AbsolutePath:

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

"/MyPage123.aspx".

: AbsolutePath

+6

Source: https://habr.com/ru/post/1740806/


All Articles