//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