0

错误如下图:

解决方案:

1:Area下的XXXAreaRegistration 添加:new string[] { "xxx.Areas.xxx.Controllers" }

2:RouteConfig 下添加 namespaces: new string[] { "xxx.Controllers" }

具体如下:

Area中:

复制代码
   public override void RegisterArea(AreaRegistrationContext context) 
        {
            context.MapRoute(
                "Admin_default",
                "Admin/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional },
                new string[] { "WebTest.Areas.Admin.Controllers" }
            );
        }
复制代码

RouteConfig 中:

复制代码
public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                namespaces: new string[] { "WebTest.Controllers" }
            );
        }
复制代码
转自: http://www.cnblogs.com/zoro-zero/p/6019431.html
关闭 返回顶部
联系我们
Copyright © 2011. 聚财吧. All rights reserved.