May 12, 2021 ASP.NET
To learn ASP.NET MVC, we'll build an Internet application.
Part 4: Add a controller.
The Controllers folder contains control classes that handle user input and responses.
MVC requires the name of all controller files to end with "Controller".
In our example, Visual Web Developer has created files: HomeController .cs (for Home and About pages) and AccountController .cs (for login pages):
Web servers typically map in-url requests directly to disk files on the server. For example, the URL request "/www.w3cschool.cn/index.php" maps directly to the file "index" on the .php.
The MVC framework is mapped differently. M VC maps the URL to the method. These methods are called "controllers" in classes.
The controller handles in-in requests, processes inputs, saves data, and sends responses back to the client.
HomeController, the controller file in .cs, defines two controls, Index and Out.
Replace the contents of the HomeController .cs file with:
The files index.cshtml and About.cshtml in the Views folder define ActionResult View Index() and About() in the controller.