views:

465

answers:

3

I'm currently working on an asp.net-mvc content management system. It would be incredibly useful to be able to deploy nested applications e.g. /shop to have a separate app inside. Or even another instance of the cms.

I've found some information around talking about limiting the inheritance of the web.config but I've no idea how this maps to an MVC application. I'm hoping as its essentially the same stack it will just run. Nothing is ever that easy though.

If anyone has any experience doing this I would be really grateful. The idea of one big application to rule them all is not at all nice.

Si.

+1  A: 

To be honest you biggest hurdle is going to be creating the routes and making sure they don't interfere with routes already in the system. After you get that working the rest is easy as pie.

The first thing you will need is an HttpModule that will be inserted in to the web.config under the . This module will be used to register and custom ViewEngines or Routes that you want to register. You do this in the same way that you do in the Global.asax but instead of putting them in the Application_Start you put them in the static constructor of the HttpModule. This is so they are only loaded once like Application_Start.

By do the above you will have created a module that is easily transportable and doesn't require the implimentor to modify their Global.asax code to get your stuff to work.

The second thing you probably want to do is create a custom configuration in the web.config to set stuff like the root path of your application. This will be prepended on to the route when you are setting it up in the HttpModule. Also you can use this to store customization information that is not appropriate for the database.

Last but not necessary is that you may want to create a custom ViewEngine that knowns and understands your folder structure. This is only necessary if you want to store the views in a different path than the default views, in order to minimize conflicts.

Nick Berardi
A: 

I've gone down this road before (with /blog), but found it to be doable but complicated and difficult to maintain. Instead I ended up using subdomains:

  • www.example.com
  • shop.example.com
  • blog.example.com

These are much easier to maintain because you can just have them work as separate websites in IIS. And, of course, you can always redirect www.example.com/shop to shop.example.com.

Keltex
This is very bad for SEO, because each domain is treated as a new website.
Nick Berardi
If he really needs to nest one ASP.NET MVC app inside another one, that could lead to really deep paths and AFAIK, search engines do not really like those, either. :)
hangy
Actually that's not true. Google changed their algorithm to treat all subdomains as the same website.
Keltex
Keltex, that is not entirely true either, Google changed the algorithm to pass reputation between domains but they are not treated as the same domain. Also the reputation passed is not the same as the reputation the one domain has, it can be best thought of as super link juice.
Nick Berardi
+2  A: 

Check out the Grouping Controllers with ASP.NET MVC from Phil Haack.

Hope it helps, Bruno Figueiredo

Bruno Shine