如何服务于多个域用一个ASP.NET MVC应用程序? [英] How to serve multiple domains with a single ASP.NET MVC application?
问题描述
如何实现一种机制(一个ASP.NET MVC应用程序内),以确保:
How to implement a mechanism (within a single ASP.NET MVC application) to ensure that:
- 如果请求来自于MYDOMAIN(用户访问mydomain.com) - >使用某些集控制器手柄
- 如果请求来自于otherdomain(用户访问otherdomain.com) - >处理使用不同的控制器集
(域的别名相同的虚拟主机)
(the domains are aliased to the same web hosting)
我应该使用ASP.NET MVC中的哪些扩展点,以确保所描述的机制的工作?
What extension points within ASP.NET MVC should I use to ensure that the described mechanism works?
推荐答案
我想你可以实现一个IRouteConstraint后裔,分析了当前HttpContext和匹配(或不匹配),根据要求的域的路由。然后,有两个不同的默认路由在Global.asax文件,各有不同的限制。
I think you could implement a IRouteConstraint descendant that analyzes the current HttpContext and matches (or does not match) a route depending on the domain requested. Then have two different default routes in your Global.asax file, each with different constraints.
我仍然preFER两个应用程序,但它是你的课程选择。
I would still prefer two applications, but it's your choice of course.
这篇关于如何服务于多个域用一个ASP.NET MVC应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!