Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

*http://localhost:1532/WebFolder/*Active.aspx

and on server I want to get this bold part

*http://domain.com/WebFolder/*Active.aspx

Similarly if page is in root it will return

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

like image 633
user576510 Avatar asked Jul 06 '11 12:07

user576510


People also ask

How do I find my local host URL?

Use the IP address 127.0. 0.1 for localhost addressing. For example, enter "http://127.0.0.1" into any web browser, and you will see a web page hosted by a web server on the same computer if one is running. Most computers and devices will also allow "http://localhost" for the same purpose.

How do I create a local host URL?

It can be done in two steps: On the server, create a virtual host like forward.mydomain.com with a reverse proxy to some unused port (say, 5000 ). Now create a tunnel so whatever comes at port 5000 on the server is tunneled to your local machine's port 3000 (PC/laptop).

Is localhost URL valid?

For example, a locally installed website may be accessed from a Web browser by the URL http://localhost to display its home page. The name localhost normally resolves to the IPv4 loopback address 127.0. 0.1, and to the IPv6 loopback address ::1.

What is a path URL?

A URL (Uniform Resource Locator) identifies a resource on a remote server and gives the network location on that server. The URL path is the string of information that comes after the top level domain name. You can use the HTTP-proxy to block websites that contain specified text in the URL path.


2 Answers

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.

Edit

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

Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath
like image 167
Pranay Rana Avatar answered Oct 08 '22 09:10

Pranay Rana


Request.Url.AbsoluteUri is the way to go

like image 44
Bergkamp Avatar answered Oct 08 '22 09:10

Bergkamp