我可以同时托管两个 MVC3 应用程序吗?
我可以在 ~/priv/ 中拥有一个 MVC3 应用程序,在 ~/pub 中拥有另一个应用程序吗?
看来,如果我首先将应用程序放在 ~/priv/ 中,那么当我访问“XXX.XXXXX.com/”时,它会为 ~/priv 中的应用程序提供服务。我可以通过路线解决这个问题吗?我有什么遗漏的吗?请帮忙!
编辑: 需要明确的是,有没有一种结构可以看起来像这样:
[root]
[priv]
[pub]
这样,如果有人进入 root,则不会看到任何人,如果有人进入 root/priv,他们会看到 priv 应用程序,如果有人进入 root/pub,他们会看到 pub应用程序。
Can I have an MVC3 application in ~/priv/, and another in ~/pub?
It seems that if I first put an application in ~/priv/ then when I go to "XXX.XXXXX.com/" it serves the application in ~/priv. Can I solve this with routes? Is there something I am missing? Please help!
Edit:
To be clear, is there a way that the structure can look like:
[root]
[priv]
[pub]
so that if someone goes to root neither one is seen, if someone goes to root/priv they the priv app and if someone goes to root/pub they get the pub app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以为每个应用程序创建子域。
You can create sub-domains for each application.
如果可以将公共和私有应用程序合并到一个 Web 应用程序中,则可以利用 Asp.net MVC 中的区域。
通过这种方式,您可以使用区域或模块将应用程序划分为更小的分组(在您的情况下是 priv 区域和 pub 区域)
事实上,Area 是应用程序中完整的 MVC 结构。
使用 ASP.NET MVC 对控制器进行分组
应用程序区域在 ASP.NET MVC 中,请学习 2
演练:组织 ASP.NET使用区域的 MVC 应用程序
If you can you merge the public and private apps in one web application you can take advantage of Areas in Asp.net MVC.
In this way you can have Areas or Module to divide the application in smaller grouping (in your case a priv area and a pub area)
In fact an Area is a complete MVC structure in you application.
Grouping Controllers with ASP.NET MVC
App Areas in ASP.NET MVC, take 2
Walkthrough: Organizing an ASP.NET MVC Application using Areas
您可以在一个站点下创建多个应用程序,并让它们使用不同的别名。
在 IIS 管理器中创建一个新网站。
右键单击该网站,然后选择“添加应用程序...”并指定别名“priv”,然后对其他“pub”网站重复该过程。
然后,您可以通过 XXX.XXXXX.com/priv/mycontoller/myaction 访问预测站点,通过 XXX.XXXXX.com/pub/mycontoller/myaction 访问另一个站点。
我想您需要在 IIS 中为此创建一个新站点,而不是仅仅将应用程序添加到现有的 ASP.Net MVC 站点 - 因为我想这会混淆路由。
You can create multiple applications under one site, and have them use different aliases.
Create a new website in IIS Manager.
Right click on that website, and choose 'Add Application...' giving the alias 'priv', and repeat that process for your other 'pub' site.
Then you can hit the predict site via XXX.XXXXX.com/priv/mycontoller/myaction and the other via XXX.XXXXX.com/pub/mycontoller/myaction.
I'd imagine that you'd need to create a new site for this in IIS, rather than just adding an application to an existing ASP.Net MVC site - as I imagine that that would confuse the routing.
您需要确保几件事:
检查设置
runAllManagedModulesForAllRequests=true
。如果 [root] 配置为应用程序,则它可能会在到达子应用程序之前拦截来自 IIS 的调用。您可能需要将以下内容添加到 [root] 的 web.config 中(但请确保在 [pub] 和 [priv] 中覆盖此内容:然后,在 [pub] 和 [priv] 的 web.config 中可以添加:
You need to make sure of several things:
Check for the setting
runAllManagedModulesForAllRequests=true
. If [root] is configured as an Application, it may be intercepting the call fro IIS before it gets to a child application. You may want to add the following to the web.config of [root] (but make sure to override this in [pub] and [priv]:Then, in web.config for [pub] and [priv] you can add: