Adding a Controller in ASP.NET Core 1.0 App


In this chapter you will learn

  1. How to add a controller in ASP.Net Core 1.0 App?
  2. HTTPGET and HTTPPOST method
  3. How to receive and send data to view page

How to add a Controller in ASP.NET Core 1.0 App?

In the previous chapter you learned what are controllers and their importance in MVC. In this chapter you will learn how to add a controller and write logic in it. So before telling you more theory about controllers why shouldn’t make a demo program. It will help you to visualize controller clearly.

Fact about Controllers

  1. Controller should be same named as View Folder. For example, if you have a folder in View Home that keeps several view pages then your controller must be same name as folder. In this condition controller name would be HomeController
  2. Every Controller must add suffix Controller For example, HomeController, UserController, ProfileController etc.
  3. To add a controller, Right Click on Controllers Folder