2013-05-07 63 views
0

我想创建MVC 4 Multitenand Application。我的问题是如何在路由中设置基础URL。设置Dynamic Base Url在多租户MVC网站中路由

这里是我的路线:

routes.MapRoute(
      name: "Default", 
      url: "{portal}", 
      defaults: new { controller = "Home", action = "Index" } 
     ); 
routes.MapRoute(
      "GameRating", 
      "{portal}/games/{name}/rates", 
      new { controller = "Game", action = "Rates" } 
     ); 
routes.MapRoute(
      "GamePlaysCount", 
      "{portal}/games/{name}/play", 
      new { controller = "Game", action = "Play" } 
     ); 

我只是想设置{}门户每租户值在Global.asax的同时,应用程序启动。 我通过请求头标识了租户,并且在我只想为我的路由设置默认门户值之后。我在控制器中过滤了门户网站信息,因此我不需要更改控制器网址。我只生成门户值的动态路由URL。

我找到了这些解决方案,但我没有整合所有东西。

  1. Determine which portal to route to in a multi-tenant MVC website
  2. Is it possible to make an ASP.NET MVC route based on a subdomain?
  3. Setup a route {tenant}/{controller}/{action}/{id} with ASP.NET MVC?

什么是你的建议吗?

谢谢...

回答