Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Is the asp-area attribute supported in asp.net core?


Asked by Leo Dickson on Nov 29, 2021 ASP.NET



The asp-area attribute sets the area name used to set the appropriate route. The following examples depict how the asp-area attribute causes a remapping of routes. Razor Pages areas are supported in ASP.NET Core 2.1 or later.
And,
An ASP.NET Core MVC app can have any number of areas. Each area has its own controllers, models, and views. Areas allow you to organize large MVC projects into multiple high-level components that can be worked on independently. Areas support multiple controllers with the same name, as long as they have different areas.
Next, Add MapControllers if the application uses attribute routing. Since routing includes support for many frameworks in ASP.NET Core 3.0 or later, the controller that adds attribute routing is participating. The following will be included:
Subsequently,
While necessary, writing this code along with the business logic feels kind of wrong. There's no separation of concerns, it makes the business logic harder to read, and it's prone to bugs. If you're using ASP.NET Core, you can use attributes and the middleware system to add this kind of logic. This makes the code looks great and separates concerns.
Also Know,
By Dhananjay Kumar and Rick Anderson. Areas are an ASP.NET MVC feature used to organize related functionality into a group as a separate namespace (for routing) and folder structure (for views). Using areas creates a hierarchy for the purpose of routing by adding another route parameter, area, to controller and action.