如何获得"主机:"从HttpContext的头(asp.net) [英] How to get "Host:" header from HttpContext (asp.net)
本文介绍了如何获得"主机:"从HttpContext的头(asp.net)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从不同的领域我的应用程序服务器部分。
要precise我应该从一个地区特定的域送达该网站的子部分。例如:
- / FR / *应从www.domain.fr服
- /英国/ *应从www.domain.co.uk服务器D
等等。
我想作的路由条目将重定向以错误的域名正确域名的请求。但我不知道如何访问HTTP头信息形式的HttpContext。
任何帮助是值得欢迎的。
解决方案
字符串requestedDomain = HttpContext.Current.Request.ServerVariables [HTTP_HOST];
字符串requestScheme = HttpContext.Current.Request.Url.Scheme;
字符串requestQueryString = HttpContext.Current.Request.ServerVariables [QUERY_STRING];
字符串requestUrl = HttpContext.Current.Request.ServerVariables [网址];
I need to server parts of my application from different domains. To be precise I have a sub section of the site that should be served from a region specific domain. For example:
- /fr/* should be served from www.domain.fr
- /uk/* should be serverd from www.domain.co.uk and so on.
I'd like to make a route entry that will redirect the request with wrong domain to the correct domain. But I don't know how to access http header information form HttpContext.
Any help is welcome.
解决方案
string requestedDomain = HttpContext.Current.Request.ServerVariables["HTTP_HOST"];
string requestScheme = HttpContext.Current.Request.Url.Scheme;
string requestQueryString = HttpContext.Current.Request.ServerVariables["QUERY_STRING"];
string requestUrl = HttpContext.Current.Request.ServerVariables["URL"];
这篇关于如何获得"主机:"从HttpContext的头(asp.net)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文