3

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.

4
  • Can you show your route setup in the global.asax? Can you get the default page to load? Commented Jan 20, 2010 at 19:04
  • I cannot get any pages to load. I can't even get a route to {*path} to be picked up. The routing code all functioned correctly prior to moving the application into a subdirectory. Commented Jan 20, 2010 at 19:18
  • 1
    "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." - Are you doing this intentionally, for a reason? This is not necessary (heck, I never even thought possible). Why not just install the MVC app as a self-contained application in the sub directory? Commented Jan 20, 2010 at 19:57
  • @Kurt: It was an undesirable hack that I had to employ due to limitations in place with the hosting company that prevent having more than one application per account. Makes me miss PHP a bit, I must say. Commented Jan 20, 2010 at 20:19

2 Answers 2

0

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
);
Sign up to request clarification or add additional context in comments.

2 Comments

Unfortunately this isn't an option because the hosting company does not support it.
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.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.