ASP.NET MVC中将控制器分离到类库的实现

2019-05-23 03:12:06于丽

第二种方法

  路由注册方法代码如下:缺点是,如果有多个注册路由的规则,都必须记得添加namespaces属性,否则会出现错误

//系统默认路由
    routes.MapRoute(
      name: "Default",
      url: "{controller}/{action}/{id}",
      defaults: new {controller = "Login", action = "Index", id = UrlParameter.Optional},
      namespaces: new string[] {"BookSystem_Controllers"}
);