标签:
1. Startup.cs 类的 Configure方法中, 加入Area路由设置代码:
//app.UseMvcWithDefaultRoute();
app.UseMvc(routes=> {
// add the new route here.
routes.MapRoute(name: "areaRoute",
template: "{area:exists}/{controller}/{action}",
defaults: new { controller = "Home", action = "Index" });
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
});
[Area("Admin")]
public class HomeController: Controller
{
public IActionResult Login()
{
return View();
}
}
标签:
原文地址:http://www.cnblogs.com/ybst/p/5212006.html