Interpretation ASP.NET 2.0 INTERNALS

xiaoxiao2021-03-06  20

Interpretation ASP.NET 2.0 INTERNALS

To translate this "insider", original http://msdn.microsoft.com/asp.net/whidbey/default.aspx?pull=/library/en-us/dnvs05/html/internals.asp

IntroductionNew features are fun and interesting to learn about, but changes to the core structure of ASP.NET speak louder to developers who really want to master the technology. In this white paper, we will cover how the internal structure of ASP.NET 2.0 has Changed Since Version 1.x. Overview ASP.NET1.0 to ASP.NET2.0 Core Structure Change

The topics covered in this paper will be of use to performance-minded developers and technical architects seeking to fine-tune (adjusted so that the regular) applications. Specifically, we will examine key areas of the code model, compilation, page lifecycle, extensibility This topic is used to focus on performance developers and technical architects to adjust the current application. And focus on the code model, compile, page survival, scalability, performance, and cache.

Code Model Code Model How an ASP.NET Web Page IS CREATED NOW CODING MODELS IN ASP.NET 1.Two Primary Options for Development A Web Form.

code-inline, works very well for simple commands. However, for more complex code, writing code-inline results in difficult to read Web pages that mix presentation (HTML) with functionality (code). Codes embedded mode applies only to simple commands code-behind Business logic and event-handling code could be written in a separate, code-only file known as the code-behind file. The code-behind model links a code-only file with the ASPX file that contains presentation tags. By separating the code from the presentation, development teams could work faster by allowing the designers to work on the presentation file while the developers worked on the code file. business logic and event handler code and display page separately the difficulties in 1.x 1. insufficient the primary difficulties x's with the code-behind model related to the way in which the code-behind file had to be synchronized with the ASPX page. Although the ASPX page inherited from the code-behind file in a programming sense, the two FILES WERE ACTUALLY COPLED BY A More Complex Relationship. This model is mainly short, background code file COD E-Behind file must be synchronized with the ASPX page. Even from the perspective of programming, the ASPX page is inherited from the background code file, and there is a more complex relationship between the two. Inheritance Complexity inheritance complexity If controls were added to the ASPX page, new code had to be added to the code-behind file. In other words, despite the inheritance relationship pointing the other way, the ASPX page actually drove the design of the Code-behind file. That is, on the one hand, although the ASPX page is inherited in Code Behind File, the ASPX page is also restricting the design of Code-Behine File.

Compilation Complexity compiled complexity All of the code-behind files were compiled into an assembly and stored in the / bin directory of the Web application. The compilation step occurred prior to deploying the application. On the other hand, the ASPX page was compiled at runtime the first time the page was requested. the ASP.NET runtime actually compiled the ASPX page into its own temporary assembly. ASPX page and code-behind file will need to be compiled, but the difference in time, code-behind file compiled before deployment And the ASPX page is temporarily compiled with the first request. The problem with this process is that the ASPX page can be changed without updating the code-behind assembly. That is, a developer may choose to modify a property or change the type of a control on an ASPX page after deployment, and the code- BEHIND FILE WOULD NOT BE Updated, Nor Would The Application Assembly Be Recompiled. It is clear that the control type of the ASPX page is modified after deployment, and the code-behind file must recompile.

Coding Models in ASP.NET 2.0 2.0 code model that ASP.NET 2.0 continues to offer both the code-inline and code-behind coding models. In terms of the code-inline model, very little has changed except for the way that Microsoft Visual Studio 2005 Supports Single-file development. 2.0 Continue to support the two code models of 1.x, for the embedded model, VS2005 supports so-called "Single-File Development" in ASP.NET 2.0, The Code-Behind File Is No Longer A full implementation of the System.Web.UI.Page class. Instead, the code-behind file is a new construct called a partial class. The partial class contains all of the user-defined code, but omits all of the plumbing (vertical? ) and connectivity code what was auto-generated by Visual Studio .NET IN ASP.NET 1.x. 2.0, the background code no longer fully implements the page class; replanting is a new class - local partial class. Partial Class contains all user-defined classes, ignoring those connected vertical code automatically generated by vs.net. When an ASPX page with a new code-behind file is requested, the ASP.NET 2.0 runtime will actually combine the ASPX page and the partial class into a single class, rather than two separate classes. Now, when a new bound When the background code of the background code is requested, the ASPX page and the local class will be combined to a single class when running, rather than the previous two different classes. The partial class uses a new keyword (Expands in Visual Basic, or Partial in C #) to indicate that the code in the class should be merged with another class at runtime. Similarly, the ASPX page uses a new directive called compilewith to indicate its association WITH THE CODE-BEHIND FILE. The local class uses the new keyword (EXPANDS IN VISUAL BASIC, OR PARTIAL IN C) to run the partial class in runtime, similarly, the ASPX page also uses the new indicator command CompileWith to associate background code. Comparison of two code-behind files in Comparing Code-Behind Files

1.xYou know that Visual Studio inserts auto-generated control declarations and initialization code This auto-generated code is a direct result of the bi-directional synchronization between the code-behind file and the ASPX file.namespace WebApplication1 {public class WebForm1.: System.Web.UI.Page {protected System.Web.UI.WebControls.Label Label1; private void Page_Load (object sender, System.EventArgs e) {} #region Web Form Designer generated code override protected void OnInit (EventArgs e) { InitializeComponent (); base.OnInit (e);} private void InitializeComponent () {this.Load = new System.EventHandler (this.Page_Load);} #endregion}} The auto-generated code not only defines the label (bold Line), IT Also Declares A New Event (Page_Load ()). 1.x, add a Label control in the ASPX page, Code-bind is automatic A declaration of the control is generated, so that the two have a two-way synchronization problem, and it has been said before, in addition,

To Be Continue ...

转载请注明原文地址:https://www.9cbs.com/read-44546.html

New Post(0)