ASP. MVC3 Series Tutorial – Web Pages 1.0

Source: Internet
Author: User

Http://www.cnblogs.com/highend/archive/2011/04/14/aspnet_mvc3_web_pages.html

I:web Pages 1.0 special files that begin with "_" (file naming is case-insensitive)

In summary, we learned that MVC3 's app initialization sequence is:
(I do not exclude other types of files that I have not found, but currently, as far as I know, the three most widely used)

Under Web pages 1.0, unless you explicitly named view with "_". Otherwise, you will encounter the following page prompts that are not available when you request a page that starts with "_"
(this figure was posted on the basis of the razor grammar. Here is to let everyone warm and know the new)

About the *.cshtml generated class name format Most page-generated assembly formats
Page compilation is compiled as a separate page into an assembly with random strings, and can of course compile n pages into 1 assemblies in a precompiled manner

II: Order of execution of special files starting with "_" in multiple directories

_appstart.cshtml can only exist in the root directory ("~/") if you place _appstart.cshtml files under subdirectories. Then the file will not be executed when the app is initialized
When accessing ~/somepage.cshtml. The ~/_pagestart.cshtml is executed first and then in the execution ~/somepage.cshtml when in the context of a complex subdirectory:

~/_pagestart.cshtml

~/sub/_pagestart.cshtml

~/sub/somepage.cshtml

Iii:web Pages 1.0 The starting principle of the detachment WebForms

First, the WEB pages take advantage of the feature to SourceFile:AssemblyInfo.cs the ASP///(System.Web.WebPages.dll)//attributeclass on the assembly itself: system.web. Preapplicationstartmethodattribute//Features: extension//parameter 1:asp.net provide for ASP.//Parameter 2: Run method name// Source: [Assembly:preapplicationstartmethod (typeof (System.Web.WebPages.PreApplicationStartCode), "Start")]//line : 15 then we can see here that the Web pages of ASP. Provide is. Web.WebPages.PreApplicationStartCode Startup method is start

public static void Start () {
    
    
    Order so we had to guard against multiple calls.
    All Start calls is made on same thread, so no lock needed here.
    if (_startwascalled) {
        Return
    }
    _startwascalled = true; Setting the Start method has been called
    Webpagehttphandler.registerextension ("cshtml");//Register extension
    Webpagehttphandler.registerextension ("vbhtml");//Register extension
    Turn off the string resource behavior which would not work on our simple base page
    pageparser.enablelongstringsasresources = false;//optimization option
    Dynamicmoduleutility.registermodule (typeof (Webpagehttpmodule));//The focus is here. ~ ~ registered a Webpagehttpmodule
    Scopestorage.currentprovider = new Aspnetrequestscopestorageprovider ();
    Requestscopestorageprovider for ASP. NET Web pages
}

ASP. MVC3 Series Tutorial – Web Pages 1.0

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.