Bug tracker: Create the ProjectController class

The Project controller contains the logic for the actions that you want to perform against the Project content type. In this tutorial, the projects are only displayed in the frontend. While in the AreaRegistration class, you defined the default action as Index.  The Index action thus returns a view populated with the available projects.

To create a controller for the Project content type:

  1. In Visual Studio, navigate to Areas » BugTracker » Controllers folder and create a new class.
    Name the class ProjectController.
  2. Make your class inherit the Controller class.
    The Controller class is located in the System.Web.Mvc namespace.
  3. Create a method to query all available projects.
    The method returns all available projects using an IQueryable. For more information how to query objects of your dynamic content type, you can refer to the generated documentation for your custom module. You can view it in the backend, on the page for configuring your custom module.
  4. Create an Index action:
    1. Create a method named Index.
    2. As a return type specify ActionResult.
    3. Call the View method of the Controller class and pass the name of the desired view (in this case “ProjectMaster”) as the viewName argument and the query for the available projects as the model argument.
    4. Return the result of the View method.

GITHUB EXAMPLE: For more information about the content of the file, see the ProjectController.cs file of the downloaded sample project.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?