views:

106

answers:

2

The view at '~/Areas/SomeArea/Views/List/Index.cshtml' must derive from ViewPage, ViewPage, ViewUserControl, or ViewUserControl.

The project structure is pretty much default. There is one area called SomeArea. It has a single controller called List. It does nothing except:

public ActionResult Index()
{
   return View("~/Areas/SomeArea/Views/List/Index.cshtml");
}

The view looks like:

@inherits System.Web.Mvc.WebViewPage<dynamic>

@{
    View.Title = "Index";
    LayoutPage = "~/Views/Shared/_Layout.cshtml";
}

<h2>Index</h2>

I have tried emptying the entire file part by part and nothing seems to help. If I create a controller and view outside the area it works just fine. Is it possible the default razor view engine doesn't support areas at this time?

Edit: The areas are registered.

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapRoute(
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters
        new { controller = "Random", action = "Index", id = UrlParameter.Optional } // Parameter defaults
    );
}

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();
    RegisterGlobalFilters(GlobalFilters.Filters);
    RegisterRoutes(RouteTable.Routes);
}

public override void RegisterArea(AreaRegistrationContext context)
{
    context.MapRoute(
        "SomeArea_default",
        "SomeArea/{controller}/{action}/{id}",
        new { controller = "List", action = "Index", id = UrlParameter.Optional }
    );
}
A: 

http://stackoverflow.com/questions/2467808/getting-the-error-the-view-at-views-page-home-aspx-must-derive-from-viewpage Similar question, might help you. Also, did you register your areas in the global.asax?

BuildStarted
A: 

An answer from the ASP.NET Forums:

http://forums.asp.net/t/1593209.aspx

This fixed the problem. Thanks to the replier!

Aaron