MVC4区域问题(已经在路径集合中)

Luc*_*ena 1 asp.net-mvc asp.net-mvc-routing asp.net-mvc-4

名为"Home_default2"的路径已在路径集合中.路线名称必须是唯一的.

    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        AreaRegistration.RegisterAllAreas();
        routes.MapRoute(
            name: "Default",
            url: "area/{controller}/{action}/{id}",
            defaults: new {area="Home_Default", controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }


        public override string AreaName
    {
        get
        {
            return "Home";
        }
    }

    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "Home_default2",
            "Home/{controller}/{action}/{id}",
            new { action = "Index", id = UrlParameter.Optional }
        );
    }
}
Run Code Online (Sandbox Code Playgroud)

自动生成的代码是错误的,我做错了什么?

Shi*_*nga 7

要解决此问题,只需删除.dll filesbin文件夹中的所有内容,然后再次构建解决方案.这应该为你解决问题.