How to Add Controller in MVC
There are two approaches to add the controller in the ASP.NET MVC.
Approach-1: Using Scaffolding method.
Approach-1: Using Scaffolding method.
- Right Click on Controller Folder
- Select Add -> Controller
- Following picture shows the controller template selected.
- Click Add button
- Name the controller as given image
- Click on the Add button and that all the controller will generate in the Controller Folder as given bellowed Image
Approach - 2: By adding a normal class
- Right Click on Controller folder
- Select Add Class or New Item
- Import the namespace using System.Web.Mvc;
- Inherit the class name Controller in it.
- And thats all the controller is ready.
Comments
Post a Comment