How to get “Host:” header from HttpContext (asp.net)

后端 未结 3 2039
时光取名叫无心
时光取名叫无心 2020-12-06 05:54

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 exam

相关标签:
3条回答
  • 2020-12-06 06:29

    I think you want Request.Headers["host"]

    0 讨论(0)
  • 2020-12-06 06:31

    HttpContext.Current.Request.Url.Host

    0 讨论(0)
  • 2020-12-06 06:43
    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"];
    
    0 讨论(0)
提交回复
热议问题