解讀ASP.NET 2.0 Internals
2024-07-10 12:56:23
供稿:網友
 
introduction
new 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. 
概述asp.net1.0到asp.net2.0核心結構的改變
the topics covered in this paper will be of use to performance-minded developers and technical architects seeking to fine-tune(調整, 使有規則) applications. specifically, we will examine key areas of the code model, compilation, page lifecycle, extensibility, performance, and caching. 
這個主題用于關注性能的開發人員和技術架構師調整現在應用程序。并專注于代碼模型、編譯、頁面生存期、可擴展性、性能和緩存等多個方面。
code model代碼模型
how an asp.net web page is created now 
coding models in asp.net 1.
two primary options for developing 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). 
代碼內嵌模式只適用于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.
商務邏輯和事件處理程序代碼與展示頁分開 
the difficulties in 1.x 1.x的不足
the primary difficulties 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 coupled by a more complex relationship.
這種模型主要不足在于,后臺代碼文件code-behind file必須與aspx頁同步。即使從編程的角度看,aspx頁是從后臺代碼文件繼承而來的,兩者之間實際上還有更復雜的關系。 
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.
就是說,一方面盡管aspx頁繼承于code behind file,但實際上aspx頁反過來也制約code-behine file的設計。 
compilation 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頁和code-behind file都需要編譯,但時間不一,code-behind file 在部署前編譯,而aspx頁則在第一請求它的時間臨時編譯。
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. 
很明顯,aspx頁的控件類型在部署后進行修改話,code-behind file必須重新編譯。
to be continued……
國內最大的酷站演示中心!