Asp.net. core tutorial,

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.