Issue with views using Areas
I am about to pull my hair out!! So I have areas setup in my MVC 3 project, I have an AccountController and Model as well as a view
When you add an area VS sets up the structure for you and I have not modified that. With all of that said, my views are not working. The controller works, when I set a breakpoint I see
// **************************************
// URL: /Account/LogOn
// **************************************
public ActionResult LogOn()
{
return View();
}
It is getting hit however I get the YPOD(Yellow page of Death) when returning the view. I have tried a view with partial rendering a开发者_运维技巧s well as the LogOn.cshtml, partial being located in the shared folder for the area and the non partial in the Views/Account folder.
Is this just broken or am I missing something?
I was missing a controller="Account" in my area registration. It now works:
public class AccountAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Account";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Account_default",
"Account/{controller}/{action}/{id}",
new { area = "Account", controller = "Account", action = "Index", id = UrlParameter.Optional }
);
}
}
精彩评论