asp.net mvc site with multiple subdomains in iis

I want to do capture subdomain as a parameter and show the appropriate information based on subdomain.

for example user1.domain.com and user2.domai.com each one get appropriate info.

possible duplicate: Is it possible to make an ASP.NET MVC route based on a subdomain?

what i have done so far:

I have a dns server with following ip address: 192.168.1.11 and a web server which host bunch of websites with ip 192.168.1.12

The site the should capture the subdomain is named pakdomain.dev

I've tried two scenarios:

after defining pakdomain.dev zone on iis and creating and "A" record with www as host and ip 192.168.1.12 on dns server

fist i have created another "A" record with "*" as host and wildcarding it to ip webserver

second i have created another "CNAME" record with "*" as host and wildcarding it to www.pakdomain.dev

in iss i have a binding with www.pakdomain.dev and pakdomain.dev to a website.

none of the above scenarios have worked for me when i goto www.pakdomain.dev or pakdomain.dev everything is fine but when i try to go to address like user1.pakdomain.dev or user2.pakdomain.dev the it goes to default website on iis.

what should id ? and how should i capture subdomain on my app?


Try this

var domain = HttpContext.Current.Request.ServerVariables["HTTP_HOST"];

That should give you the host header information and then use the value to route to wherever it is you want to go.

链接地址: http://www.djcxy.com/p/70374.html

上一篇: Facebook访问令牌的过期时间更长

下一篇: 在iis中有多个子域的asp.net mvc站点