如何ASP.NET页面解析? [英] How Does ASP.NET Parse Pages?

查看:114
本文介绍了如何ASP.NET页面解析?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找一篇文章,将深入了解ASP.NET如何工作以及如何呈现XML标记控制。例如,引擎盖下,如何ASP.NET采取以下的标记并让它产生我们看到的结果?

I'm looking for an article that will dive deep into how ASP.NET works and how it renders controls from XML markup. For example, under the hood, how does ASP.NET take the following markup and have it produce the results we see?

<asp:Label ID="MyLabel"><%= myObject.Text%></asp:Label>

是否有人知道的任何物品,将深入了解ASP.NET的内部运作?

Does anybody know of any article that will dive deep into the inner workings of ASP.NET?

推荐答案

会发生什么引擎盖下,是每一个ASP.NET页面被编译成一个.NET类,就像任何其他。控件(ASCX)所编制的方式相同。没有为ASP.NET标记编译器就像有对C#和VB.NET编译器 - 你能想到的ASP.NET标记为另一种语言,编译为本地MSIL的

What happens "under the hood" is that each ASP.NET page is compiled into a .NET class, just like any other. Controls (ASCX) are compiled the same way. There is a compiler for ASP.NET markup just like there is a compiler for c# and VB.NET - you can think of the ASP.NET markup as "yet another" language which compiles to native MSIL.

本机ASP.NET标记由 PageParser 处理。您可能会注意到这个类有一个有趣和非常有益的方法 - <一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.pageparser.getcompiledpageinstance.aspx\">GetCompiledPageInstance.因为这意味着,它编译页面以本地.NET类。这可以被覆盖(例如,你可以拿出自己的标记,写自己的解析器/编译)。 星火是一个流行的替代ASP.NET标记。

The native ASP.NET markup is handled by the PageParser. You may notice this class has one interesting and very useful method - GetCompiledPageInstance. As it implies, it compiles the page to a native .NET class. This can be overridden (e.g., you could come up with your own markup and write your own parser/compiler). Spark is a popular alternative to ASP.NET markup.

每个类最终从或的Control 。这两个类都呈现其中,在类的执行它的定制功能结束时,您已经实现了()方法,编写HTML输出流。

Each class ultimately inherits from Page or Control. Both of these classes have Render() methods which, at the end of the class's executing its custom functionality you have implemented, write HTML to an output stream.

最大的区别是在编译经常发生在一个非常不同的时间要比C#或VB.NET code。这是不是一个真正的技术要求这么多,因为它是一个功能,允许去耦从功能.NET语言的presentation .NET语言。 ASPX和ASCX页面由ASP.NET运行时,要求他们在一个Web服务器的情况下进行编译。编译后的程序集,然后保存在内存中,直到一个)Web应用程序关闭或b)在ASPX文件中的一个检测文件系统的变化,引发了重新编译。

The big difference is that the compilation often happens at a much different time than the c# or VB.NET code. This is not really a technical requirement so much as it is a feature that permits decoupling the presentation .NET language from the functional .NET language. ASPX and ASCX pages are compiled by the ASP.NET runtime when they are requested in the context of a web server. The compiled assemblies are then held in memory until a) the web application shuts down or b) a filesystem change is detected in one of the ASPX files, triggering a recompile.

它可以编译您的ASPX页面旁边的C#/ VB.NET /什么,这样你就可以部署整个应用程序作为一个部件。这有两个好处 - 之一,明显轻松部署单个DLL的。其次,它消除了常常伴随着第一击到ASP.NET Web应用程序的 LOOOONG 的等待时间。由于所有的页是precompiled,组件只需要代替编译每个文件在第一请求被加载到存储器,

It is possible to compile your ASPX pages alongside your c#/VB.NET/whatever, so you can deploy the entire application as a single assembly. This has two advantages - one, the obvious ease of deploying a single DLL. Second, it eliminates the LOOOONG wait time that so often accompanies a "first hit" to an ASP.NET web application. Since all the pages are precompiled, the assembly simply needs to be loaded into memory upon first request, instead of compiling each file.

这篇关于如何ASP.NET页面解析?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆