[SOLVED] how to get URL path on local host and on server?


Plase guide me how to get URL path excluding page name on localhost and server.

for example for the page Active.aspx local path that I want to get is here in bold.


and on server I want to get this bold part


Similarly if page is in root it will return

*http://domain.com/Active.aspx or *http://localhost:1532/**Active.aspx


Request.ApplicationPath – Gets the ASP.NET application’s virtual application root path on the server.

Request.Path – Gets the virtual path of the current request.


To get domain + current request + virtual path of the current application, try below:

Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath

Answered By – Pranay Rana

Answer Checked By – Marilyn (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *