Super simple MVC site with an Area to handle mobile devices. All of my Area routing works fine with the exception of a view that expects a parameter.
In the "normal" site I have a view video page that expects a parameter.
mysite.com/Video/123456
This works perfectly. After fighting this for a bit in my Area for the mobile content I have even gone down to using the exact same code/markup in my Controller and View. So I would expect that the following URL:
mysite.com/Mobile/Video/123456
Would resolve properly. It doesn't. I get a 404 (not found). If I take the parameter off:
mysite.com/Mobile/Video
It resolves properly.
I am sure this must be something I am doing wrong in the routing. Below is the appropriate section from my global.asax. Any help would be appreciated.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Video", // Route name
"Video/{id}", // URL with parameters
new { controller = "Video", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new string[] { "mysite.Controllers.VideoController" }
);
routes.MapRoute(
"NewsItem", // Route name
"NewsItem/{id}", // URL with parameters
new { controller = "NewsItem", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new string[] { "mysite.Controllers.HomeController" }
);
routes.MapRoute(
"Mobile", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { area = "Mobile", controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new string[] { "mysite.Areas.Mobile.Controllers.HomeController" }
);
routes.MapRoute(
"Mobile/Video", // Route name
"Mobile/Video/{id}", // URL with parameters
new { area = "Mobile", controller = "Video", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new string[] { "mysite.Areas.Mobile.Controllers.VideoController" }
);
}