Asp.net knowledge

Source: Internet
Author: User

    I spent a month in my spare time solving all the basic things of Asp.net. I felt a little faster, but I still had to look back at the basics.

At the beginning, we may be able to get started immediately. aspx files with General suffixes, So we naturally started to write code here. At first we didn't know why we were writing this, so we started to get started, new students can review with me.

Single file Model

 

When we encounter MVC or use webform's <% =###%> to simulate the MVC effect, do we have such questions, that is, the returned values of background code can be called at the front end, so some people started this experiment <% for (INT I = 0; I <100; I ++) {#######}%> the result can indeed be executed normally, so we know that <%> is very powerful, but it seems still boring, you can write a return value, but write a piece of code. There is still a CS file in the background that is not needed. Isn't that a slap in the air? So let's trace the source, the original method is found. We only need to create an HTML page and change the suffix to Aspx.

1 <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml"> 2 

The result is run in the browser, where HTML code and C # code are mixed in a single page (<SCRIPT runat = "server" Language = "C #"> ), it seems that the one-to-one relationship looks beautiful, but as long as the amount of code goes up, it is a headache and it is not easy to maintain.

The example just tells new students that this is the case, but it is not practical.

Background code model

 

This is not much mentioned, because it is a model that everyone is using. the only thing worth mentioning is that the compiled instruction is ignored by others. Due to the impetuousness of many people, I have not paid much attention to it, we will explain it based on the original command:

<% @ Page Language = "C #" autoeventwireup = "true" codefile = "backstagefile. aspx. CS "inherits =" backstagefile "%> the class name autoeventwireup defined in the background code inherits indicates whether page events are automatically matched.

Of course, we can also see the direct difference between aspx and HTML suffixes, that is, the ASPX page can inherit from the background, so we can know whether the final compilation of aspx is

Class.

Conclusion: compare the two modes

  • * **. Aspx the single-file model is compiled into the *** _ aspx class (inherited from the system. Web. uipage class) by. Net runtime ).
  • ***. The aspx background code model is finally created. net runtime compiled into *** _ aspx class (inherited from system. web. uipage class ,***. aspx. the CS file is used to define some code snippets of the web control ***. all Web controls and events extracted from aspx ]).

Application folder


We are familiar with the definition of Reserved Words and keywords for each language library and runtime framework. For a framework that has been used for web development like Asp.net, it is necessary to set certain types of your own reserved or key formats. Therefore, the concept of Application folders appears. Of course, we can regard it as a retained (key) folder, since these folders are retained, we cannot rename them at will. Otherwise, if the system crashes or you crash, what are the Application folders?

App_browsers

Contains the browser definition (. browser) file used by ASP. NET to identify individual browsers and determine their functions. For more information, see browser definition file architecture (browsers element) and how to: delete browser types and features in ASP. NET web pages.

App_code

Contains the source code of the Utility Classes and business objects (such as. CS,. VB, And. jsl files) that you want to compile as part of the application. In a dynamically compiled application, ASP. NET compiles the code in the app_code folder when it sends the first request to the application. Then re-compile the items in the folder when any changes are detected.

DescriptionYou can place any file type in the app_code folder to create a strongly typed object. For example, you can place a web service file (. WSDL and. XSD files) in the app_code folder to create a strongly typed proxy.

The code in the app_code folder will be automatically referenced in the application. In addition, the app_code folder can contain subdirectories of files to be compiled at runtime. For more information, see the shared code folder in the ASP. NET Website and the codesubdirectories element of compilation (ASP. NET setting architecture ).

App_data

Contains application data files, including MDF files, XML files, and other data storage files. ASP. NET 2.0 uses the app_data folder to store the local database of the application. This database can be used to maintain membership and role information. For more information, see membership introduction and role management.

App_globalresources

Contains resources (. resx and. Resources files) that are compiled into an assembly with a global scope ). Resources in the app_globalresources folder are strongly typed and can be accessed by programming. For more information, see ASP. NET web page resource overview.

App_localresources

Contains resources (. resx and. Resources files) associated with a specific page, user control, or master page in the application ). For more information, see ASP. NET web page resource overview.

App_themes

Contains a collection of files (. Skin and. CSS files, image files, and general resources) used to define the appearance of ASP. NET web pages and controls ). For more information, see ASP. NET themes and appearances.

App_webreferences

Contains the reference protocol file (. WSDL file), schema (. XSD file), and discovery document file (. disco and. discomap files) used to define web references used in applications ). For more information about generating XML Web Services Code, see Web Services Description Language tool (wsdl.exe ).

Bin

The compiled assembly (. dll file) that contains the controls, components, or other code you want to reference in the application ). In the application, any class represented by the code in the bin folder will be automatically referenced. For more information, see the shared code folder on the ASP. NET Website.

 

Dynamic compilation and pre-Compilation

For example, we have created a website or web application in a solution, and some people are still discussing their compilation form. Some people say that the Web application must be generated once before execution, as a result, we did our own test and the results were totally nonsense, as long as a website or web application does not depend on external assembly (such as the three-tier architecture generated **. DLL), which is fully dynamically compiled at this time, that is, it is automatically compiled when we browse the page, and will exist in the cache after the first compilation, if the file is not modified, it does not need to be re-compiled; otherwise, it will be automatically re-compiled. Maybe you have questions about how it is linked to the page after it is compiled into an assembly, we just need to follow the diagram to explain, c: \ windows \ Microsoft. net \ framework \ v4.0.30319 \ temporary ASP. net files \ you will find a lot of compiled assembly of the program you have previously created. We open a folder containing the compiled assembly of website and find the suffix ***. when you open the compiled file, you will suddenly realize that it will not be demonstrated here. You will understand it after you open it.

Pre-compilation is actually because we usually release a website or a Web application depending on external assembly. "pre-" means that the pre-compiled content must be written in advance, of course, you must note that the file names of each generated program are randomly generated, rather than fixed.

 

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.