Reputation: 82297
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.
Upvotes: 2
Views: 667
Reputation: 4993
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]:
<?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>
Upvotes: 2
Reputation: 4181
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
Upvotes: 0
Reputation: 4770
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.
Upvotes: 3