.net core Areas区域

  //使用MVC

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                        name: "areas",
                        template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
                    );
                routes.MapRoute(
                    name: "default",
              template: "{controller=Home}/{action=Index}/{id?}");
                //template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
            });

新建Base控制器

    [Area("Backstage")]
    public class BaseController : Controller
    {
        //public IActionResult Index()
        //{
        //    return View();
        //}
    }

新建控制器

    public class HomeController : BaseController
    {
        public IActionResult Index()
        {
            ContentResult content = new ContentResult();
            content.Content = "text=0123456789";
            return content;
        }
    }

访问: http://localhost:52768/backstage
posted @ 2019-12-20 16:18  enych  阅读(720)  评论(0编辑  收藏  举报