Asp.net. core tutorial,
Asp.net. core tutorial (translated from Microsoft official documentation https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/adding-controller)
This tutorial will teach you how to use vs2017 to build a basic asp.net. core Service Program.
This tutorial teaches the controllers and views of asp.net. core.
The Razor page is a new choice for using asp.net. core.
MVC stands for model, view, and controller)
Model: indicates the application data, used to confirm the logical rules of business data. It is often used to store databases.
View: The View shows the interface for users. Generally, data in the Model is displayed on the interface.
Controller, used to process browser requests. Obtain data from the model and hand it to the view to be responded.
In an MVC program, view only displays information. controlle is responsible for responding to user requests and interactions.
The MVC mode allows you to divide an application into different parts (input logic, business logic, and interface logic) and make each part a loose combination.
Dividing into different parts helps you deal with complicated applications. You only need to pay attention to one part of each modification without affecting other parts.
The public methods in each controller become the end of http. Note the comment before each method (indicating to access the corresponding URL of the controller class ).
In web programs. Each http end is a valid url.
MVC wakes up the corresponding control class based on the next URL to be selected, such as http: // localhost: 62474/HelloWorld/Welcome/3? Name = jack
Modify the default start page of MVC.
App. UseMvc (routes =>
{
Routes. MapRoute (
Name: "default ",
Template: "{controller = Home}/{action = Index}/{id ?} ");
});
The above id can be used as a flag of the default query field, without the need to write a paragraph name.
Http: // localhost: 62474/HelloWorld/Welcome can be left blank.
HtmlEncoder. Default. Encode the core on the official website cannot apply System. Web. dll. Instead, use WebUtility. HtmlEncode to reference System. Net;
Formatting can prevent malicious attacks.
$ "Hello {name}, NumTimes is: {numTimes}" indicates the interpolation string.