总的来说,ASP.NET到底是什么哪?(翻译)

扼要翻译《Programming Microsoft ASP.NET》关于什么是ASP.NET的一节

What's ASP.NET, Anyway?

Prior to the advent of ASP.NET, three main technologies and platforms were available to develop Web applications: ASP, Java Server Pages (JSP), and the open source Web platform commonly referred to as LAMP (Linux plus Apache plus MySQL plus either Perl, Python, or PHP as the programming language).
在ASP.NET的前面,已经有三种主要的技术和平台用来开发Web应用了,它们分别是ASP、JSP和LAMP。

Note 

For completeness, we should also mention a couple of platform-specific, lower-level technologies that ASP and JSP rely on. ASP is actually an Internet Server Application Programming Interface (ISAPI) extension, whereas JSP is implemented as a special servlet application. ISAPI extensions on IIS-based platforms and servlets on Java-based systems let you create server-side, Web-deployed applications using a more classic approach. You write a module that builds and renders the page rather than declaratively design the page using a mix of markup text and embedded code.
完整地,我们也要知道ASP和JSP分别基于的平台相关的底层技术细节。ASP实质上是服务器编程接口(ISAPI)的一个扩展,而JSP则是服务器一个特殊的servlet应用程序。两者类似地使你能一般的方法创建“服务器端”Web分发式应用程序。

Although each has language-specific and architecture-specific features, all these Web development platforms are designed to create interactive pages as part of a Web-based application. To some extent, all enable developers to separate programming logic from the page layout through the use of components that the page itself is responsible to call and render. Aside from this common ultimate终极 goal, significant differences exist among those platforms, most of which relate to the programming model and languages they promote and support. For example, JSP exploits利用 the Java framework of classes and, with JavaBeans, provides an effective extensibility model for reusing components. In addition, JSP supports tag customization and lets developers associate code with a custom tag definition. Finally, because it's a key element of the Java 2 Enterprise Edition (J2EE) platform, JSP relies on the Java language, a first-class language as opposed to the scripting languages used by both ASP and LAMP platforms. So how does ASP.NET fit in exactly?
几种Web应用开发平台的终极目标是创建“交互页”,最好能用“组件”从页面中提取编程逻辑。三种平台由于使用不同的编程模型和支持语言,也存在不少差异。比如JSP,利用JAVA框架类—JAVA豆,提供了高效的扩展模型用于重用组件。此处还提供些自定义标签什么的。还有,JSP使用JAVA作为处理语言,而ASP和LAMP是使用脚本。那么ASP.NET呢?

Like ASP and other Web development environments, ASP.NET also works on top of the HTTP protocol and takes advantage of HTTP commands and policies to set up two-way, browser-to-server communication and cooperation. What really differentiates ASP.NET from the plethora of other Web development technologies—and what makes it especially revolutionary—is the abstract programming model it propounds提出, the Web Forms model. In addition, the whole ASP.NET platform comes as a native part of the Microsoft .NET Framework. To be sure you grasp揪住 the importance of this last point, let me explain. ASP.NET applications are now compiled pieces of code, are made of reusable and extensible components, can be authored with first-class languages (including C#, Microsoft Visual Basic .NET, JScript .NET, and J#), and can access the entire hierarchy of classes in the .NET Framework.
和过去的技术一样,ASP.NET也是工作在HTTP协议上的,也要处理HTTP命令,也要处理浏览器-服务器交互操作,那么ASP.NET的革命性在哪里呢?革命在一种新抽象编程模型—Web Forms模型!此外,ASP.NET是Microsoft .NET Framework平台重要组成部分,这点很重要。得益于.NET Framework,ASP.NET应用现在是编译型应用,由可重用和扩展的组件组成,也使用编译语言处理逻辑了。此外还可以访问.NET Framework整个强大的类库。

In short, ASP.NET combines the best of all worlds. It is syntax compatible (and to a large extent, also language compatible) with ASP. It provides the same object-oriented features as JSP applications (tag customization, first-class compiled languages, components, extensibility, and reusability). And as icing on the cake, ASP.NET delivers a wealth of goodies, tools, and powerful system features that can be effectively grouped within the blanket expression tools for abstracting the HTTP programming model. Lots of programmer-friendly classes let you develop pages using typical desktop methods. The Web Forms model promotes an overall event-driven approach, but it's deployed over the Web and has the potential to target any vendor's platform through the support of XML.
简单的说,ASP.NET把全部的好东西组合在一起了。与ASP语言语法兼容,提供与JSP一样面向对象功能,自定义标签、编译语言、组件、可重用性和可扩展性。ASP.NET带来的功能可以用一句话来总结—用来抽象HTTP编程模型的工具集。大量的强大简单的类使你能使用开发桌面应用的方法来开发页面。

Note 

From a technical point of view, ASP.NET adopts the best of the ASP and JSP programming models. Conversely, it doesn't inherit much from the LAMP platform in terms of technical aspects. The appeal of LAMP is that it excels as a robust and extensible (because it is open-source) platform with flourishing and proactive grassroots community sites and Web boards.
LAMP 平台的确有一些特别,保留……

Programming in the Age of Web Forms
编程在WEB表单新纪元

A key point I need to explain so that you understand the rationale behind the ASP.NET Web Forms model is that there is a need to provide a better strategy to deal with the strong and growing demand for cheap Web interaction. As a matter of fact, the HTTP protocol, especially its stateless nature, creates a sort of bottleneck for the development of Web applications. On the other hand, the inherent固有的 simplicity of HTTP is the key to its worldwide adoption and effectiveness—in short, we probably couldn't have the Internet as we know it without a protocol like HTTP. Yet, as demand increases, programmers have to devise发明设计 better ways of setting up easy and effective communication from the client to the server and vice versa.
我来解释一下一个关键点,随着现在对“廉价的WEB交互”日益需求,ASP.NET 提供一种更好的策略—Web Forms模型。实际上,正是因为工作在HTTP协议上,尤其是它的无状态的性质,已经成开发WEB应用的一大瓶颈了。话说回来,就是因为HTTP固有的简单性,才是它在全球内普及的关键,简单的说,如果没有像HTTP这样的协议,也就没有今天的互联网了。所以,有求必应,程序员必须发明设计出更好方法促使客户端-服务器交互更容易更有效。

Various techniques have been experimented with over time to smooth the communication across different pages and across multiple invocations招唤请求 of the same page. Programmers are used to thinking in terms of a client-generated action that results in a server-side reaction. Such a basic and fundamental pattern simply cannot be accomplished, at least not literally, over the Web. A certain degree of abstraction and some system-provided services are needed to make smooth communication happen. Although they aren't perfect, JSP and ASP let programmers target any browser while coding against a relatively familiar and understandable model. ASP, much more than JSP, thinks declaratively and has quite a slim稀少 and scanty缺乏的 object model. Overall, programmers who become Web programmers are forced to adopt a different mindset and toss the familiar action/reaction paradigm out the door.
过去的一些日子里,已经有相当的一些技术实现了在不同页面间或者被多次请求的同一页之间成功交互了。程序员必须细心考虑每一个客户端产生的动作以及服务器作相应的反应。这样的一种开发模式在Web上并不能很容易完成。……

Event-Driven Programming over HTTP
HTTP上的事件编程

With Web Forms, the event-driven model of interaction finally comes to the Web. Implementing an event model over the Web requires any data related to the client-side user's activity to be forwarded to the server for corresponding and stateful processing. For the model to work, the server needs to process the output of client actions and trigger reactions while being aware of the overall state of the application. The state of the application contains two types of information: the state of the client and the state of the session. The state of the client is easily accessible through the syntax and the implementation of the <form> HTML element. But what about the overall state of the session?
直接明了的事件编程模式最后还是来到WEB世界了。要在WEB上实现事件模型,必须把客户端的活动数据送到服务器端作相应的状态处理。模型的工作是,服务器必须关注应用程序的整个状态,并且要对的客户端的输出和触发动作作处理。应用程序状态包含两种信息:客户端状态信息和会话信息。通过语法和HTML的表单元素,客户端状态信息很容易访问,不过会话信息呢?

As mentioned, HTTP is a stateless protocol, which means two successive requests across the same session are resolved by newly instantiated environments in which no session-specific information is maintained, except all the information the application itself might have stored in global objects. In ASP, reentrant forms are a common way to work around such a system limitation. A reentrant form is an HTML <form> element that posts to the same page that contains it. Reentrant forms alone do not fully solve the issue. However, by combining them with code blocks and hidden fields storing state information that is critical for the page, many developers elegantly overcame克服 the obstacle障碍.
如前面提及,HTTP是无状态协议,这意味着,连续的两请求的会话信息是不会被维持的。在ASP里,自提交表单是解决这一限制的常用方法。单独的自提交表单是不能完全解决问题的,必须把代码块和隐藏字段结合起来保存页面的关键的状态信息才行。很多开发人员已经优雅地克服了这个问题了。

What was once an ASP best-practice has been standardized and integrated in the ASP.NET runtime to become the key feature that endows ASP.NET applications with automatic state maintenance. The ASP.NET runtime carries the page state back and forth across page requests. When generating HTML code for a given page, ASP.NET encodes and stuffs the state of server-side objects into a few hidden, and transparently created, fields. When the page is requested, the same ASP.NET runtime engine checks for embedded state information—the hidden fields—and utilizes any decoded information to set up newly created instances of server-side objects. The net effect of such a mechanism is not unlike the Windows Forms model on the desktop and is summarized in Figure 1-1.
一度是ASP最佳练习的状态问题,现在已经标准化并集成到ASP.NET的运行时里去了,同时,状态的自动维护也成了ASP.NET应用的一大特色。ASP.NET运行时让所有页面请求的往返过程携带状态信息。在生成HTM页面时,ASP.NET会将相关的服务器端对象的状态信息进行编码,并透明地将这些信息填到一些隐藏字段随页面返回。当页面被请求时,ASP.NET引擎将检查这些内藏的状态信息,解码后,再根据这些信息再建服务器端对象。

The Windows Forms model stems from the typical event-driven desktop programming style. No matter what connectivity exists between the client and server components, the server always works in reaction to the client's input. The server is aware of the overall application state and operates in a two-tier, connected manner. The Web Forms model needs some machinery to support the same event-driven programming model. In Figure 1-1, the needed machinery is represented by the state deserialization that occurs when the page is requested and the state serialization performed when the HTML response is being generated.
WEB表单模型需要一些机制来支持“事件驱动编程模型”,表现在页面在往和返两个方面,deserialization previous state处理请求页面前反串行化之前的状态信息,serialization current state 处理请求页面后返回前串行化当前状态

The ASP.NET object model is a branch of the .NET Framework and is designed to provide a server-side counterpart to virtually any HTML page elements, such as HTML tags like <form> and <input> and page-wide tags like <link> and <script>. In addition, the ASP.NET object model includes numerous components (called server controls or Web controls) that represent more complex elements of the user interface (UI). Some of these controls have no direct mapping with individual HTML elements but are implemented by combining multiple HTML tags. Typical examples of complex UI elements are the Calendar control and the DataGrid control. An ASP.NET page is made of any number of server controls mixed with verbatim字面 text, markup, and images. Sensitive data excerpted from the state of each constituent构成的 control is silently stored in hidden fields, and it forms the context of that page request. The association between an instance of the page and its state is unambiguous, not programmatically modifiable, and controlled by the ASP.NET HTTP runtime. We'll delve more deeply into this topic in Chapter 2, which also covers the Web Forms architecture in detail.
ASP.NET对象模型,不是组件模型哦,是.NET框架的一个分支,设计用来提供HTML的可视化元素在服务器端的代替物,比如,HTML标签<form><input>,page-wide标签<link><script>。此外,这个对象模型还包括很多复杂的元件,这些元件表现用户介面一些比较的复杂一点的元素,比如calender月历,数据网格datagrid等。一张ASP.NET页包含这样的一些可视化元素—服务器控件。还有一个秘密,就是这些服务器控件的状态信息会被这个运行时收集放到一些隐藏域里去,用来重整这张页的上下文。因此,运行时可以无误地将页面实例与其上下文进行关联。

Building a Server-Side Abstraction Layer
创建一服务器端抽象层

Every conversation between browsers and Web servers consists of the exchange of packets similar to the ones we have just examined. If the requested URL is an HTML page, the Web server typically reads the contents of the .html file and flushes it into the body of the response packet. If the URL is an ASP.NET page, a special IIS module gets involved. The module is an IIS plug-in known as an ISAPI extension. An ISAPI extension is a dynamic-link library (DLL) registered on a per-file extension basis. An ISAPI extension registered to handle .aspx files will get involved whenever a request comes in for this type of resource.

The ISAPI extension analyzes the request and uses any contained information to configure the server-side environment that will actually process the source of the page.
这个配置服务器环境,根据提交过来的信息,怎么配置,或者简单配置什么东东,有,会话,ASP里,那么提交过来的HTTP头里会有甜饼,里面有会话ID 的。

While processing the page request, the ISAPI extension parses the body of the request and exposes any information found through a more programmer-friendly object model. For example, instead of remaining a simple name/value string, the EmpCode variable is moved within an application-wide collection—the Request.Form collection. This represents a first level of abstraction built over the raw HTTP programming model. Objects such as Request, Response, and Server form the HTTP context for the call and, as such, represent the minimum set of objects you find in all Web development platforms, including JSP, ASP and, of course, ASP.NET. In ASP.NET, though, you find much more
你玩过的东东,Request, Response, and Server 被再正名为“在没加工过的HTTP编程模型”的第一层抽象。

阅读更多
个人分类: 应用开发
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭