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:

  1. In Visual Studio, navigate to Areas » BugTracker folder and create a new class.
    Name the class BugTrackerAreaRegistration.
  2. Make your class inherit the AreaRegistration class.
    The AreaRegistration class is located under the System.Web.Mvc namespace.
  3. Implement the abstract members of the AreaRegistration class.
    The AreaRegistration class has the following abstract members:
    • AreaName
      A property that returns the name of your area.
    • RegisterArea
      A method that is used to map a route for your area.
  4. Configure the AreaName property to return the name of your area.
    In the getter of the property, return the “BugTracker” value.
  5. In the RegisterArea method, map a route for your area:
    1. Call the MapRoute method of the context argument.
    2. As the name argument pass the name of your route.
    3. As the url argument pass the template of your URLs.
    4. 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.

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?