How to use an Area in ASP.NET Core

前端 未结 8 752
[愿得一人]
[愿得一人] 2020-11-28 23:45

How do I use an Area in ASP.NET Core?

I have an app that needs an Admin section. This section requires its Views to be placed in that area. All request

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 23:59

    Scaffolding has generated all the files and added the required dependencies.

    However the Application's Startup code may required additional changes for things to work end to end. Add the following code to the Configure method in your Application's Startup class if not already done:

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

提交回复
热议问题