Create an AreaRegistration class
You create the AreaRegistration class to map one or more routes. The routes define the template of the URL used to navigate to the different views.
To create an area registration class for your application:
- In Visual Studio, navigate to Areas » BugTracker folder and create a new class.
Name the class BugTrackerAreaRegistration.
- Make your class inherit the AreaRegistration class.
The AreaRegistration class is located under the System.Web.Mvc namespace.
- Implement the abstract members of the AreaRegistration class.
The AreaRegistration class has the following abstract members:
A property that returns the name of your area.
A method that is used to map a route for your area.
- Configure the AreaName property to return the name of your area.
In the getter of the property, return the “BugTracker” value.
- In the RegisterArea method, map a route for your area:
- Call the MapRoute method of the context argument.
- As the name argument pass the name of your route.
- As the url argument pass the template of your URLs.
- As the defaults argument pass the default values for the action and the id elements of the URL.
The default action in the BugTracker sample is Index (that is, querying of the available content items) and the default ID is an empty string.
GITHUB EXAMPLE: For more information about the content of the file, see the BugTrackerAreaRegistration.cs file of the downloaded sample project.