views:

389

answers:

2

I am attempting to deploy an ASP.NET MVC application in a subdirectory of an existing application and I am running into some routing issues. I have set up the folder structure such that all of the binaries and config files for the MVC app are correctly located in the root directory, while the rest of the content is in the subdirectory. Additionally, I updated all of the routes in the MVC application to reflect the subdirectory; however, every request to the application produces:

The incoming request does not match any route.

All defined routes are being ignored, including the default route:

routes.MapRouteLowercase(
    "Main_Default",
    "blog/{controller}/{action}/{id}",
    new { controller = "Home", action = "Index", id = "" }
);

I tried enabling RouteDebug to test the issue, but even that is not getting routed to. Any advice on what else I can try?

Note: This question is not a duplicate.

A: 

Try running it as a virtual directory instead of just a directory, otherwise your routes are not going to be called. You will not need to put the name of the virtual directory in the route.

Here's a route that I have setup in a v-dir MVC app that works just fine...

routes.MapRoute(
    "Default",                                              // Route name
    "{controller}/{action}/{id}",                           // URL with parameters
    new { controller = "Tour", action = "Index", id = "" }  // Parameter defaults
);
Brian
Unfortunately this isn't an option because the hosting company does not support it.
Nathan Taylor
MVC is an application level type thing. You will need to setup the routes in the roots global.asax file. You will also need to put the project dll in the bin directory under the root and I believe the Views have to live under the root as well (though there might be a way around that). If you want the url to include the word blog in it, you can leave the route that you created. Remember that routes don't have anything to do with the physical file structure other than some conventions defined by the MVC team.
Brian
A: 

Looks like I found the problem.

In addition to the binaries and the config files, Global.asax must also be placed in the root in order for its code to be executed.

Thanks guys. :)

Nathan Taylor