开发者

HttpContext.Current.Request.Url.Host return incorrect value

开发者 https://www.devze.com 2023-03-19 16:38 出处:网络
My web url is www.test.com and I try to get this URL by HttpContext.Current.Request.Url.Hostbut it return IP Address instead of that URL. I check by fiddler and it Host is also IP Address. I want to k

My web url is www.test.com and I try to get this URL by HttpContext.Current.Request.Url.Host but it return IP Address instead of that URL. I check by fiddler and it Host is also IP Address. I want to know how to f开发者_StackOverflow中文版ix this?


Use below to fetch url from code:

string url = HttpContext.Current.Request.Url.ToString().Trim(); 


You are getting the IP since you are trying to use the Host property of the URL. You should see the AbsoluteUri property of URL to get complete URL Info. e.g.

String url = HttpContext.Current.Request.Url.AbsoluteUri;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号