Areas are a way for you to segregate functionality within your website. For example, anything related to the admin area goes in one place—for example, a physical folder, including its own controllers, views, and so on. In terms of views, the only thing worth mentioning is how we can configure the paths where view files can be found. This is controlled through the AreaViewLocationFormats collection of the RazorViewEngineOptions class, as illustrated in the following code snippet:
services
.AddMvc()
.AddRazorOptions(options =>
{
options.AreaViewLocationFormats.Add("/SharedGlobal
/Areas/{2}.cshtml");
});
The included values are the following ones:
- /Areas/{2}/Views/{1}/{0}.cshtml
- /Areas/{2}/Views/Shared/{0}.cshtml
- /Views/Shared/{0}.cshtml
Here, the {2} token stands for the area name...