c# - How to know what host is being called -


i have web app in c# , want redirect app depending on host being called on site... example if call www.domain.com want app redirected folder called site1 if call www2.domain.com want app redirected site2. these example names.. it's same site different operations. dns stuff being taken care of, no worries. must www , ww2 pointing same server ip address.

thanks lot guys..

(sorry if title not clear, didn't knew how ask question properly)

your code should inspect httpcontext.current.request.url.host.

example:

string host = httpcontext.current.request.url.host switch (host.tolower()) {     case "www.domain.com":         httpcontext.current.response.redirect("~/site1");         break;     case "www2.domain.com":         httpcontext.current.response.redirect("~/site2");         break;     default:         httpcontext.current.response.statuscode = 500; } 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -