简体   繁体   中英

HttpContext.Current.Request.Url giving 127.0.0.1

While debugging in Visual Studio which is running at following URL http://localhost:39452/ I am getting http://127.0.0.1 as the value for following property

 HttpContext.Current.Request.Url

instead of http://localhost:39452/ I am having this value in my hosts file:

::1  localhost

Can you let me what I am doing wrong here?

Perhaps you are trying to get the HttpContext.Current.Request.Url value too early.

For example; during the Init event of a HttpModule you may face with these kind of problems. I mean you may get http://127.0.0.1/myApp instead of the correct value of http://localhost/myApp .

Both are localhost; ::1 is the shorthand notation of the IPv6 version and 127.0.0.1 is the IPv4 version.

I guess your assumption that you are doing something wrong, is the only thing you're doing wrong! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM