views:

137

answers:

2

Meaning I could have the URL routing start at like site.com/v3/site/controller/action

basically it would ignore the v3/site/ and treat that as root?

A: 

It sounds like the the application root is at /v3/site. As far as I know, ASP-MVC's routing can't intercept routes below its own root (would likely be a security issue). Seems more like an IIS configuration that's needed than an MVC routing rule.

statenjason
+3  A: 

You sure can. Check out the following routes:

routes.MapRoute("Route1", "StaticFolder/{name}/{id}", new { controller = "Controller1", action = "Action1", name = "Sample", id = "1" });

Route 1 will always invoke Action1 on Controller1 on any requests for resources in StaticFolder.

routes.MapRoute("Route2", "StaticFolder1/{id}/{action}", new { controller = "Controller2", action = "Action2", id = "1" });

Route 2 will always invoke Controller2 with specified action (defaulting to Action2) for any requests to StaticFolder1.

In your case specifically though you want to remove the default route and replace it with the following:

routes.MapRoute("Default", "/v3/site/{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" });
Darko Z
routes.MapRoute("Default", "/v4/shell/{controller}/{action}/{id}", New With {.controller = "Demo", .action = "Test", .id = ""}) DID NOT WORK...
shogun
What's the real root path within your application? Does the application have a virtual path (for example myhost.com/myapp/) or does it start at myhost.com/ ?
Terje