开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜