views:

284

answers:

2

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?

A: 

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!

Josh E
Thanks for the tip on the debugger.
Esteban Araya
no problem - hope it helps!
Josh E
+1  A: 

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

meandmycode
It's good to know routes are app relative. I was hoping that would be the case. I currently don't have a web.config in my root folder. Do you think that could still be the problem? I'll try what you suggest anyhow. Thanks!
Esteban Araya
@meandmycode: I dont' think I have problems with paths. I made the all fully qualified.
Esteban Araya
Are you use the tilde syntax to describe app relative? ie: ~/something vs /something
meandmycode
Can I just confirm you setup an application using your hosting providers control panel, and you dumped everything from the result of a publish into a folder in the root named the same as the application you just created?
meandmycode
@meandmycode: Yup, sure on paths. Yes, I just created a folder, made it and app, and then dumped everythng in there. I'll keep looking. I think I'll figure it out w/ the debugger.
Esteban Araya
The only thing I can suggest is making a blank mvc application and see if that works ok, this would let you determine if theres an issue with the configuration on the server, or something specific to your app.
meandmycode