Hello friends, I hope you all are doing great. In today's tutorial, we are gonna Create a New Controller in ASP.NET MVC. It's 6th tutorial in our ASP.Net MVC series. We have already had a look at basic Introduction to Controllers in ASP.NET MVC and they are used to communicate between Views & Models.
So, now we are gonna have a look at How to Create a New Controller in ASP.NET MVC. It's a very quick tutorial, as there's not much to do with Controller rite now, we will just create one. So, let's get started with it:
Create a New Controller in ASP.NET MVC
In order to Create a New Controller in ASP.NET MVC, you have to right click on the Controllers folder in Solution Explorer.
Now click on the Add and then click on Controllers as shown in below figure:
It will open up a new window which will have different types of Controllers and are used for different purposes.
Here, we have to select the second one as we want to perform read/ write actions.
So, select MVC 5 Controller with read / write actions and then clock Add Button, as shown in below figure:
When you click the Add Button, it will ask for the Controller name.
I have assigned it a name StudentController, now click the Add button, as shown in below figure:
Now when we click the Add button, then a scaffolding operation will start by visual studio and it will automatically create our new controller.
This new Controller file will also open up in our work space and it will have some classes by default in it, as shown in below figure:
We have successfully created our new Controller to read or write data.
So, now we are only left with the Views which we are gonna create in our next tutorial and will also bind them together.
Here's a video demonstration of How to Create a new Controller in ASP.NET MVC, it will help for better understanding:
So, that was all about How to Create a New controller in ASP.NET MVC. If you have any questions, then ask in comments and I will surely help you out. Thanks for reading. Take care.
syedzainnasir
I am Syed Zain Nasir, the founder of The Engineering Projects (TEP). I am a
programmer since 2009 before that I just search things, make small projects and now I am sharing my
knowledge through this platform. I also work as a freelancer and did many projects related to
programming and electrical circuitry. My Google Profile+Follow
Get Connected
Comments on ‘’ Create a New Controller in ASP.NET MVC ‘’ ( 0 )