[Original] Mvc learning notes (1), original mvc learning notes

Source: Internet
Author: User

[Original] Mvc learning notes (1), original mvc learning notes
1. Create an MVC4 Project

Protected void Application_Start () {AreaRegistration. registerAllAreas (); WebApiConfig. register (GlobalConfiguration. configuration); FilterConfig. registerGlobalFilters (GlobalFilters. filters); // register a route. Only one RouteConfig is registered when the website is requested. registerRoutes (RouteTable. routes); BundleConfig. registerBundles (BundleTable. bundles );}Introduction to MVC Razor templates

In the ASPX module, we use <%>. However, in the Razor template, we use the @ symbol.

In the Razor template, we use @ {}, which indicates a code segment, which means to write C # code in "{}". The powerful aspect of the Razor template engine is that, it automatically recognizes the <> symbol and considers "<>" as the html code and outputs it with the @ symbol.

For example:

@ {String msg = "Haha"; <input type = "text" value = "@ msg"/> @ msg

<Text> Hello </text>}

Because Razor view engine recognition <> is there any good way to output the "hello" text in the code segment of the html page? You may want to use the label <span> Hello </span>. If we want to disable the label, we need to use the label <text> Hello </text>, this is the original text provided by the template, without tags.

Advantages of MVC development: differences between MVC and L3

I believe that many children's boots are often asked about the differences between MVC and Layer 3 during interviews. The homepage MVC is the development method of the presentation layer and has nothing to do with Layer 3. MVC is a design model of the presentation layer, A development method used to remove the UI and Business Code.

MVC knowledge

In MVC, the methods in the controller must be defined as public and the Controller class must be public if they are to be accessed by browsers. Otherwise, they cannot be accessed, the Controller class name must end with the Controller and inherit from the Controller class. in net mvc, the agreed Controller must inherit from the Controller at the end, but you can do the same, but you need to configure it, but try to follow the agreement, this is very convenient, this is the so-called Convention that exceeds the configuration.

 

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.