Reputation: 29664
I have an MVC website I've been developing and I now wish to move up to my shared hosting service. However, I've run into a bit of a problem: my provider only allows for 1 root level application.
When I created and application as a sub of my root application, my MVC app wouldn't work. I'd either get a "resource not found" or, after adjusting my routes to contain the subfolder name", a "there are not matching routes" error.
So my question is, what do I have to do? How do I adjust my routes? Does the fact that my root application is not an MVC app matter?
Upvotes: 0
Views: 867
Reputation: 17317
Firstly you don't change the route names, they should be app relative.
Secondly, you'll probably experience problems from web.config inheritance (ie, your web.config in the mvc application is inheriting everything from the web.config in the root).
You can stop this inheritance but you'll need to modify the root applications web.config to include a location tag around everything:
<configuration>
<configSections>
... all your custom config sections here (if any) ...
</configSections>
<location path="." inheritInChildApplications="false">
... all your config stuff here (ie, system.web, connectionStrings) ...
</location>
</configuration>
What this does is says, apply these settings only to the path '.', the period will stand for the current location, then the inheritInChildApplications says 'don't inherit these settings in child applications'.
You can even put things outside of the location tag that you DO want to share to child applications.
Edit: note this may not fix your problems (or at least not all of them), some may be because you've made assumptions that the application will run in the root (mainly regarding paths).
Upvotes: 1
Reputation: 7434
It shouldn't matter that your root isn't configured as an MVC app, but you do need to make sure that the /bin/ directory at least has the MVC assemblies, if they are not in the GAC. Try using Phil Haack's route debugger to see if there are any issues with the routes. That could give us some more information if not help you to fix the problem!
Upvotes: 0