ASP.NET MVC `Html.ActionLink` between “Areas”

后端 未结 6 548
灰色年华
灰色年华 2021-01-31 01:58

I have added a new Area to my MVC3 project and I am trying to link from the _Layout page to the new Area. I have added an Area called \'Admin\' that has a controller \'Meets\'.<

6条回答
  •  醉酒成梦
    2021-01-31 02:31

    Verify that your AdminAreaRegistration class looks like this:

    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 { action = "Index", id = UrlParameter.Optional }
            );
        }
    }
    

    and that you have this in Global.asax.cs:

    protected void Application_Start()
    {
        ... // ViewEngine Registration
        AreaRegistration.RegisterAllAreas();
        ... // Other route registration
    }
    

提交回复
热议问题