在asp.net mvc的动态子域 [英] Dynamic subdomains in asp.net mvc
问题描述
我是相当新的asp.net,并与IIS的经验。我想有我的应用程序的每个用户获得自己的子域名,但都使用相同的控制器。子站点将控制显示哪些内容。
I am fairly new to asp.net, and have little experience with iis. I would like to have each user of my application get their own sub-domain, but all use the same controllers. The subdomain would then control what content is displayed.
例如:
user1subdomain.mydomain.com/Whatever
user2subdomain.mydomain.com/Whatever
都将使用相同的控制器。理想的情况是一个参数可以给用户名到控制器,然后可以显示相应的内容。我想它足够灵活,新的子域可以被添加到数据库,无需重写规则路由每一个新的子域添加的时间。
Will both use the same controller. Ideally a parameter could give the user name to the controller, which could then display the appropriate content. I would like it to be flexible enough that new subdomains could be added to the database without rewriting routing rules every time a new subdomain is added.
推荐答案
MVC未绑定到域,只是路径(如的http://域名/路径)。
MVC is not bound to the domain, just to the path (e.g. http://domain/path).
要正确你需要做以下...
To do this properly you need the following...
- 通配符DNS设置为
* .yourdomain.com指向你的服务器。 - 在IIS设置的站点
没有主机头。任何其他网站
托管在IIS上该实例
相同的IP必须具有主机头
指定。 - 您的应用程序将需要检查
请求主机头无论是在页面加载,
会话启动或其他一些事件。
这篇关于在asp.net mvc的动态子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!