简体   繁体   中英

HttpContext.Current.Request.Url.Authority is getting cached by IIS

I have a web application (asp.net, C#) running for more than 2 months for internal employees of my company. The application was accessible by live IP address like 121.XXX.XX.200.

In my code-base, I used "HttpContext.Current.Request.Url.Authority" to get this particular IP address. This was also working fine till day before yesterday.

However, yesterday the code "HttpContext.Current.Request.Url.Authority" started giving me local IP address of the server like "10.X.XXX.20" instead of the live one.

Now I was able to reproduce the error. Whenever I browse the application using the local IP address, IIS seems to be caching the domain name. Now when I browse the same application using live IP address from different computer. It still gives me the local IP.

What can be the solution to this?

Try using HttpContext.Current.Request.Url.Host instead of HttpContext.Current.Request.Url.Authority .

As long as I remember Authority gets the DNS domain name of host which can cause problems sometimes.

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