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:
- In Visual Studio, navigate to Areas » BugTracker » Controllers`` folder and create a new class.
Name the classProjectController. - Make your class inherit the
Controllerclass.
TheControllerclass is located in theSystem.Web.Mvcnamespace. - Create a method to query all available projects.
The method returns all available projects using anIQueryable. 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. - Create an
Indexaction:- Create a method named
Index. - As a return type specify
ActionResult. - Call the
Viewmethod of theControllerclass and pass the name of the desired view (in this case“ProjectMaster”) as theviewNameargument and the query for the available projects as themodelargument. - Return the result of the
Viewmethod.
- Create a method named
GITHUB EXAMPLE: For more information about the content of the file, see the ProjectController.cs file of the downloaded sample project.
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
Get started with Integration Hub | Sitefinity Cloud
This free lesson teaches administrators, marketers, and other business professionals how to use Sitefinity Integration Hub to create automated workflows between Sitefinity and other business systems.
Web Security for Sitefinity Administrators
This free lesson teaches administrators the basics about protecting your Sitefinity instance and your sites from external threats. 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 ASP.NET Core and take advantage of its decoupled architecture and modern development model.