I am trying to use the Maarten Balliauw Domain Route class to map subdomains to regions in an MVC2 application, so I have URLs like:
http:
instead:
http://mydomain.com/admin/home/index
So far, I have only had partial success. Execution is routed to the right controller in the correct area, but then cannot find the correct view. I get the following error:
The view 'Index' or its master was not found. The following locations were searched:
~/Views/AdminHome/Index.aspx
~/Views/AdminHome/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
This tells me that MVC only looks for a view in the root views folder, and not in the views folder within the Area. If I copy the view from the Area Views folder to the root views folder, the page will look great. This, however, completely destroys the purpose of dividing the APP into Regions.
I define the route for the area as:
public class AdminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get { return "Admin"; }
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.Routes.Add(
"Admin_Default"
, new DomainRoute(
"admin.localhost"
, "{controller}/{action}/{id}"
, new { controller = "AdminHome", action = "Index", id = UrlParameter.Optional }
));
}
}
, , .