一 创建一个区域
Asp.Net Core区域的使用_第1张图片
二 在startup.cs文件中添加区域路由

  app.UseMvc((RouteBuilder) => 
            {
                RouteBuilder.MapRoute("Admin", "{area:exists}/{Controller}/{Action}/{Parameter}", new { @Controller = "Home", @Action = "Index", @Parameter = String.Empty });
                RouteBuilder.MapRoute("default", "{Controller}/{Action}/{Parameter}", new { @Controller = "Home", @Action = "Main", @Parameter = String.Empty });
            }
            );

三 在相应的controller类上使用注解

 [Area("Admin")]
    public class HomeController : Controller
    {

        public IActionResult Index()
        {
            return View();
        }
    }