ASP.NET Core Pitfalls – Areas
There are a few problems with using areas:
- The _ViewImport.cshtml and _ViewStart.cshtml files are not loaded by views inside an area, which means that, for example tag helpers registrations are lost and page layouts are not set. The solution is either to copy these files to a view folder inside the area, such as:
Areas\Admin\Views\Home\_ViewImport.cshtml
or to copy the files to the root of the application. - You should register the area routes before the other routes:
endpoints.MapControllerRoute("areas", "{area:exists}/{controller=Home}/{action=Index}/{id?}");