ASP.NET MVC 2 Areas, Strange routing behavior

Posted by user137348 on Stack Overflow See other posts from Stack Overflow or by user137348
Published on 2010-04-24T13:15:02Z Indexed on 2010/04/24 13:23 UTC
Read the original article Hit count: 225

Filed under:
|
|

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 = "" }
        );
    }
}

© Stack Overflow or respective owner

Related posts about asp.net-mvc-2

Related posts about areas