HttpContext.Current.Request.Url giving 127.0.0.1

asp.net, c#, iis-7.5, windows-7

Solution

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`.

Problem

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?

Original source