Asp.net After a Server.Transfer how do you get the path of the current page

asp.net

To get the url of the current page, I usually do something like this:

string path = Request.Path;

If I do this after a Server.Transfer then I get the path of the page where the transfer was done. How can I get it for the current page?

For example:

On Page1.aspx I do Server.Transfer ("Page2.aspx")
On Page2.aspx Request.Path returns /Page1.aspx and not /Page2.aspx

I would like to get /Page2.aspx. How can I get it?

Best Solution

You're looking for the Request.CurrentExecutionFilePath property.