I need to check my subdomain name (or if theres no subdomain) in asp.net. Right now i tested by adding s.localdev.com to my host files and use it to visit my asp.net page. Request.Url gives me localhost instead 开发者_如何学运维and RawUrl just gives me what is after the /. (Path and query i think its called). How do i get the full domain so i can check my sub domain?
Request.Url.Authority
Or Request.Url.GetLeftPart(UriPartial.Authority)
You might need to remove the http(s)://
prefix.
Also look at Request.ServerVariables["HTTP_HOST"]
Request.Url.AbsoluteUri
should do the trick
精彩评论