标签:title asp mvc service public ted 就是 style mapr
Areas 提供了一种把大型 ASP.NET Core MVC Web 应用程序分为较小的功能分组的方法,用到了区域那区域路由就必不可少,下面简单实现区域路由的两种方式
1 //路由 2 routes.MapRoute(name: "areaRoute", 3 template: "{area:exists}/{controller=MyHome}/{action=Index}"); 4 5 //controller添加属性 6 [Area("Manage")] 7 public class UserInfoController : Controller 8 { 9 private readonly IUnitOfWork _unitOfWork; 10 private readonly IUserInfoService _userInfoService; 11 12 public UserInfoController(IUserInfoService userInfoService, IUnitOfWork unitOfWork) 13 { 14 _unitOfWork = unitOfWork; 15 _userInfoService = userInfoService; 16 } 17 public IActionResult Index() 18 { 19 return View(); 20 } 21 }
1 routes.MapAreaRoute("Manage_route", "Manage", 2 "Manage/{controller=MyHome}/{action=Index}/{id?}" 3 );
标签:title asp mvc service public ted 就是 style mapr
原文地址:https://www.cnblogs.com/wodemingtian/p/8995186.html