我可以同时托管两个 MVC3 应用程序吗?

发布于 2024-12-22 06:47:52 字数 347 浏览 2 评论 0原文

我可以在 ~/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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

乖乖哒 2024-12-29 06:47:53

您可以为每个应用程序创建子域。

You can create sub-domains for each application.

泅人 2024-12-29 06:47:53

如果可以将公共和私有应用程序合并到一个 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

浪漫人生路 2024-12-29 06:47:52

您可以在一个站点下创建多个应用程序,并让它们使用不同的别名。

在 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.

不如归去 2024-12-29 06:47:52

您需要确保几件事:

  • 虚拟目录 [pub] 和 [priv] 必须各自配置为 IIS 中的应用程序。
  • 如果 [root] 配置为应用程序,则子文件夹中的任何应用程序都将继承 web.config 中的值,即使它们在不同的应用程序池下运行也是如此。确保这不会导致冲突或意外行为。
  • 检查设置runAllManagedModulesForAllRequests=true。如果 [root] 配置为应用程序,则它可能会在到达子应用程序之前拦截来自 IIS 的调用。您可能需要将以下内容添加到 [root] 的 web.config 中(但请确保在 [pub] 和 [priv] 中覆盖此内容:

    
    <配置>
        <系统.web服务器>
        <模块 runAllManagedModulesForAllRequests="false">
                <删除名称=“UrlRoutingModule-4.0”/>
            
        
    
    
  • 然后,在 [pub] 和 [priv] 的 web.config 中可以添加:

    <模块 runAllManagedModulesForAllRequests="true">
        <添加名称=“UrlRoutingModule-4.0”类型=“System.Web.Routing.UrlRoutingModule”/>
    
    

You need to make sure of several things:

  • The virtual directories [pub] and [priv] must each be configured as an Application in IIS.
  • If [root] is configured as an application, any applications in sub folders will inherit the values from web.config, even if they run under a different app pools. Make sure this is not causing a conflict or unexpected behavior.
  • 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]:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.webServer>
        <modules runAllManagedModulesForAllRequests="false">
                <remove name="UrlRoutingModule-4.0" />
            </modules>
        </system.webServer>
    </configuration>
    
  • Then, in web.config for [pub] and [priv] you can add:

    <modules runAllManagedModulesForAllRequests="true">
        <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" />
    </modules>
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文