Reference "ASP. MVC5 Advanced Programming" version 5th
2nd Chapter Controller
Controller: Responds to the user's HTTP request and returns the processed information to the browser.
2.1 ASP. NET MVC Introduction
The controller in the MVC pattern is primarily responsible for responding to the user's input and modifying (Model) in response. In this way, the controller in MVC focuses on the application flow, the processing of the input data, and the provision of the associated View data source
In the MVC pattern, the URL first tells the route which controller to instantiate, which method to invoke, and provides the required parameters for the method. The controller then determines which view to use and renders the view.
The URL is not directly related to the file system on the Web server, but rather to the method of the Controller class. MVC provides the result of a method call, rather than a dynamically generated page.
Tips
- Using method Httputility.htmlencode to preprocess user input prevents users from injecting JavaScript code or HTML markup into the view with links. Like:www.meishizouqi.com?<script> window.location= ' http://www.example.com ' <script>
Reference "ASP. MVC5 Advanced Programming" version 5th
ASP. MVC5 Advanced Programming Chapter 2nd Controller