Aspnetcore.docs: 3.1 update: Areas

Created on 27 Nov 2019  Â·  3Comments  Â·  Source: dotnet/AspNetCore.Docs

These instructions do not work for .NET Core 3.0. There is no more app.useMVC. Please instruct how to do this with endpoints and/or AddControllersWithViews. Thank you.

@Rick-Anderson edit: 10K PV


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

  • ID: 50249794-b4be-a6aa-d7b3-b3918eb282bf
  • Version Independent ID: 39d98269-a7dc-017f-55cd-bd33df097368
  • Content: Areas in ASP.NET Core
  • Content Source: aspnetcore/mvc/controllers/areas.md
  • Product: aspnet-core
  • Technology: aspnetcore-mvc
  • GitHub Login: @Rick-Anderson
  • Microsoft Alias: riande
Source - Docs.ms doc-enhancement

Most helpful comment

This is how I'm doing it in core 3.1:

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "areaRoute",
                    pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });

All 3 comments

+1 today core 3.1 is out

This is how I'm doing it in core 3.1:

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "areaRoute",
                    pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });

Thanks @DrewBrasher
I got caught up trying to use MapAreaControllerRoute instead of just MapControllerRoute.

Was this page helpful?
0 / 5 - 0 ratings