Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localhost and request.Url.Authority

My application separates users by company identifiers in the URL: company1.app.com, company2.app.com...

I am testing on my local PC with a request such as: company1.localhost.com. However, my request.Url.Authority still shows "localhost.com" instead of "company1.localhost.com". In fact, the prefix of 'company1' does not show anywhere. Is this a bug or a feature?

It's worth noting that I added to the host file an entry for "comapany.Blah -> 127.0.0.1". When looking at Request.Url.Authority it STIL shows localhost...

like image 265
Cachor Avatar asked Nov 28 '10 22:11

Cachor


People also ask

How do I find my localhost URL?

Usually, you can access the localhost of any computer through the loopback address 127.0. 0.1. By default, this IP address references a server running on the current device. In other words, when your computer requests the IP address 127.0.

What is URL authority?

The Authority part of the URL is the host name and the port of the URL.

What is request URL AbsoluteUri?

Url. AbsoluteUri is returning "http://www.somesite.com/default.aspx" , when the Url in the client's browser looks like "http://www.somesite.com/". This small diffrence is causing a redirect loop.


1 Answers

Do not use the Authority, but use the Host

Request.Url.Host

The authority search back on dns, the host get the site from the url. When you search the dns you get the first name of your ip address that you have connected with that name and not all names.

like image 113
Aristos Avatar answered Oct 10 '22 05:10

Aristos