ASP.NET MVC 2 Areas, Strange routing behavior
- by user137348
I've created an Area named "Admin". I've created also a controller(Pages) and a view(List) in this areas.
When I run my app and enter the url "/Admin/Pages/List" I'm getting an The resource cannot be found error.
When I enter /Pages/List, the Action method is hit but the view is not found,because the app is searching in wrong directories
~/Views/Pages/List.aspx
~/Views/Pages/List.ascx
~/Views/Shared/List.aspx
~/Views/Shared/List.ascx
the view is in /Admin/Pages/List.
My routing conf for Admin area:
public class AdminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Admin";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { controller= "Pages",action = "Index", id = "" }
);
}
}