版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、毕业论文(设计)外文翻译外文原文Building ASP.NET Web Pages Until now, all of the example applications in this text have focused on console-based and desktop GUI-based front ends. In the next three chapters, youll explore how the .NET platform facilitates the construction of browser-based presentation layers using a
2、 technology named ASP.NET. To begin, youll quickly review a number of key web-centric concepts ( , HTML, client-side scripting, and server-side scripting) and examine the role of Microsofts commercial web server (IIS) as well as the ASP.NET development web server, WebDev.WebServer.exe. With this web
3、 primer out of the way, the remainder of this chapter concentrates on the structure of ASP.NET web pages (including the singleand code-behind model) and examines the composition of a derived type. This chapter also introduces the role of the Web. config file, which will be used in the web-centric ch
4、apters to come. The Role of Web applications are very different from traditional desktop applications (to say the least).The first obvious difference is that a production-level web application will always involve at leasttwo networked machines (of course, during development it is entirely possible t
5、o have a singlemachine play the role of both the browser-based client and the web server itself). Given the natureof web applications, the networked machines in question must agree upon a particular wire proto-col to determine how to send and receive data. The wire protocol that connects the compute
6、rs inquestion is the Hypertext TransferProtocol ( ).The Request/Response CycleWhen a client machine launches a web browser (such as Opera, Mozilla Firefox, or Microsoft Internet Explorer), an request is made to access a particular resource (typically a web page) on the remote server machine. is a te
7、xt-based protocol that is built upon a standard request/response paradigm. For example, if you navigate to , the browser software leverages a web technology termed Domain Name Service (DNS) that converts the registered URL into a four-part, 32-bit numerical value, termed an IP address. At this point
8、, the browser opens a socket connection (typically via port 80 for a nonsecure connection) and sends the request for processing to the target site.The web server receives the incoming request and may choose to process out any client-supplied input values (such as values within a text box, check box
9、selections, etc.) in order to format a proper response. Web programmers may leverage any number of technologies (CGI, ASP,ASP.NET, JSP, etc.) to dynamically generate the content to be emitted into the response. At this point, the client-side browser renders the HTML sent from the web server. Figure
10、31-1 illustrates the basic request/response cycle.Figure 31-1.The request/response cycle Is a Stateless ProtocolAnother aspect of web development that is markedly different from traditional desktop programming is the fact that is essentially a stateless wire protocol. As soon as the web server emits
11、 a response to the client, everything about the previous interaction is forgotten. This is certainly not the case for a traditional desktop application, where the state of the executable is most often alive and kicking until the user shuts down the application in question.Given this point, as a web
12、developer, it is up to you take specific steps to “remember” information (such as items in a shopping cart, credit card numbers, home and work addresses, etc.) aboutthe users who are currently logged on to your site. As you will see in Chapter 33, ASP.NET provides numerous ways to handle state, many
13、 of which are commonplace to any web platform (session variables, cookies, and application variables) as well as some .NET-particular techniques such as the ASP.NET profile management API.Understanding Web Applications and Web ServersA web application can be understood as a collection of files (*.ht
14、m, *.asp, *.aspx, image files, XML-based file data, etc.) and related components (such as a .NET code library or legacy COM server) stored within a particular set of directories on a given web server. As shown in Chapter 33, ASP.NET web applications have a specific life cycle and provide numerous ev
15、ents (such as initial startup or final shutdown) that you can hook into to perform specialized processing during your websites operation. A web server is a software product in charge of hosting your web applications, and it typicallyprovides a number of related services such as integrated security,
16、File Transfer Protocol (FTP) support, mail exchange services, and so forth. Internet Information Services (IIS) is Microsoftsenterprise-level web server product, and as you would guess, it has intrinsic support for classicASP as well as ASP.NET web applications.When you build production-ready ASP.NE
17、T web applications, you will often need to interact with IIS. Be aware, however, that IIS is not automatically selected as an installation option when you install the Windows operating system (also be aware that not all versions of Windows can supportIIS, such as Windows XP Home). Thus, depending on
18、 the configuration of your development machine, you may wish to install IIS before proceeding through this chapter. To do so, simply access the Add/Remove Program applet from the Control Panel folder and select Add/Remove Windows Components. Consult the Windows help system if you require further det
19、ails.Note:Ideally, your development machine will have IIS installed before you install Visual Studio 2008.If you install IIS after you install Visual Studio 2008,none of your ASP.NET web applications will execute correctly (you will simply get back a blank page).Luckily, you can reconfigure IIS to h
20、ost .NET applications by running the aspnet_regiis.exe command-line tool and specifying the /i option.Assuming you have IIS properly installed on your workstation, you can interact with IIS fromthe Administrative Tools folder (located in the Control Panel folder) by double-clicking the Internet Info
21、rmation Services applet. For the purposes of this chapter, you are concerned only with the Default Web Site node (see Figure 31-2).Figure 31-2.The IIS applet The Role of IIS Virtual DirectoriesA single IIS installation is able to host numerous web applications, each of which resides in a virtual dir
22、ectory. Each virtual directory is mapped to a physical directory on the hard drive. Therefore, if you create a new virtual directory named CarsRUs, the outside world can navigate to this site using a URL such as :/ CarsRUs (assuming your sites IP address has been registered with the world at large).
23、 Under the hood, this virtual directory maps to a physical root directory on the web server, such as C:inetpubwwwrootAspNetCarsSite, which contains the content of the CarsRUs web application.As you will see later in this chapter, when you create ASP.NET web applications using VisualStudio 2008, you
24、have the option of having the IDE generate a new virtual directory for the current website automatically. If required, you are certainly able to manually create a virtual directory by hand by right-clicking the Default Web Site node of IIS and selecting New Virtual Directory (or on Vista, simply Add
25、 Virtual Directory) from the context menu.When you select the option to create a new virtual directory, you will be prompted for the name and physical folder that will contain the web content. To illustrate working with IIS (and to set us up for our first web example), create a new directory on your
26、 hard drive that will hold yet-to-be-generated web content. For this discussion Ill assume this directory to be C:CodeTestsCarsWebSite. Now, right-click the Default Web Site node of IIS to create a new virtual directorynamed Cars that maps to this new directory. Figure 31-3 shows the end result.Figu
27、re 31-3.The Cars virtual directoryWe will add some content to this website in just a moment.The ASP.NET Development ServerPrior to .NET 2.0, ASP.NET developers were required to make use of IIS virtual directories during the development and testing of their web content. In many cases, this tight depe
28、ndency on IIS made team development more complex than necessary (not to mention that many network administrators frowned upon installing IIS on every developers machine). Thankfully, we now have the option to use a lightweight web server named WebDev.WebServer.exe. This utility allows developers to
29、host an ASP.NET web application outside the bounds of IIS. Using this tool, you can build and test your web pages from any directory on your machine. This is quite helpful for team development scenarios and for building ASP.NET web programs on versions of Windows that do not support IIS installation
30、s (such as Windows XP Home).Note WebDeve cannot be used to test or host classic (COM-based) ASP web applications. This web server can host only ASP.NET web applications and/or .NET-based XML web services.When building a website with Visual Studio 2008, you have the option of using to host your pages
31、 (as you will see a bit later in this chapter). However, you are also able to manually interact with this tool from a Visual Studio 2008 command prompt.If you enter the following command: WebDev.WebServer.exe -?you will be presented with a message box that describes the valid command-line options. I
32、n a nut-shell, you will need to specify an unused port (via the /port: option), the root directory of the webapplication (via the /path: option), and an optional virtual path using the /vpath: option (if you donot supply a /vpath: option, the default is simply /). Consider the following usage, which
33、 opens anarbitrary port to view content in the C:CodeTestsCarsWebSite directory created previously:WebDev.WebServer.exe /port:12345 /path:C:CodeTestsCarsWebSite Once you have entered this command, you can launch your web browser of choice to request pages. Thus, if the CarsWebSite folder had a file
34、named , you could enter the following URL: :/localhost:12345/CarsWebSite/Default.aspx Many of the examples in this chapter and the next will make use of via Visual Studio 2008, rather than hosting web content under an IIS virtual directory. While this approach can simplify the development of your we
35、b application, do be aware that this web server is not intended to host production-level web applications. It is intended purely for development and testing purposes. Once a web application is ready for prime time, your site will need to be copied to an IIS virtual directory.Note The Mono project (s
36、ee Appendix B) provides a free ASP.NET plug-in for the Apache web server. This makes it possible to build and host ASP.NET web applications on operating systems other than Microsoft Windows.The Role of HTMLNow that you have configured a directory to host your web application, and you have chosen a w
37、eb server to serve as the host, you need to create the content itself. Recall that “web application” is simply the term given to the set of files that constitute the functionality of the site. To be sure, a vast number of these files will contain tokens defined by Hypertext Markup Language (HTML). H
38、TML is a standard markup language used to describe how literal text, images, external links, and various HTML-based UI widgets are to be rendered within the client-side browser.This particular aspect of web development is one of the major reasons why many programmersdislike building web-based progra
39、ms. While it is true that modern IDEs (including Visual Studio2008) and web development platforms (such as ASP.NET) generate much of the HTML automatically, you will do well to have a working knowledge of HTML as you work with ASP.NET.Note Recall from Chapter 2 that Microsoft has released a number o
40、f free IDEs under the Express family of products (such as Visual C# Express).If you are interested in web development, you may wish to also download Visual Web Developer Express. This free IDE is geared exclusively at the construction of ASP.NET web applications.While this section will most certainl
41、y not cover all aspects of HTML (by any means), lets checkout some basics and build a simple web application using HTML, classic (COM-based) ASP, and IIS. This will serve as a road map for those of you coming to ASP.NET from a traditional desktop application development background.Note If you are al
42、ready comfortable with the overall process of web page development , feel free to skip ahead to the section “Problems with Classic ASP.”译文:网页的生成目前为止,这篇文章中所有的示例程序都集中在基于控制台和基于桌面GUI的前端。在下面的三节中,你将知道.net平台如何使用技术构建基于浏览器的表示层,首先,快速回顾一下以网络为中心的几个概念( ,html,客户端脚本,服务器端脚本),然后了解微软商业web服务器(IIS)和环境web服务器:WebDev.WebS
43、erver.exe.为了找到网站入门的方法,这一章的其余部分集中在网页的结构上(包括单网页和代码隐藏模型),同时还研究了网页派生类型的组成。另外还介绍了网页配置文件的作用,它将在以web为中心的章节中出现。 的作用Web应用程序同传统的桌面程序是有很大不同的(至少可以这么说).最明显的区别是:生产级别的网络应用程序通常包含至少两个连网机器(当然,在开发过程中,它完全有可能有一个由机同时扮演基于浏览器的客户端和服务器端的角色)。由于网络应用程序的性质,相关的网络设备必须有一个特有的协议,以确定怎样发送和接收数据。这个连接计算机的协议就叫做超文本传输协议( ). 请求/响应的过程当一个客户机启动了
44、web浏览器(例如Opera浏览器,火狐浏览器,微软的IE浏览器),一个 的请求就被用来在远程服务器上访问特殊资源(通常是一个web页面), 是一个基于文本的协议,是基于标准请求/响应模式创建的。举个例子,如果你浏览到,浏览器软件利用了一种叫做DNS域名服务的网络技术,它将注册的URL转化成四个部分,32位二进制数,我们把它称为IP地址。这时,浏览器打开了一个套接字连接(通常通过非安全性80端口建立连接),然后发送 请求来处理目标站点。服务器端接收了输入的 请求,并选择处理客户端提供的输入信息(这些信息可以是文本框,可选择的复选框等).以便使 响应格式化。Web程序员可以利用一些技术(CGI,
45、ASP,ASP.net,JSP等)来动态的产生相应的内容。这时,客户端浏览器翻译从服务器端发来的HTML,下面的图31-1说明了基本 请求/响应的过程。图31-1 请求/响应过程 是一个无状态的协议web开发另一个明显区别于传统桌面程序的是: 是一个无状态的协议,当web服务器对客户端做出响应时,所有早期的联系都结束。这当然不是一个传统的桌面应用程序,它执行的状态一直是变化的,直到用户关闭正在使用的程序。从这一点上来说,作为网络开发者,由你来制定具体的步骤来“存储”那些当前登陆到你网站的用户信息(例如购物手推车中的列表项,信用卡号,家庭和工作地址等)。你将在第33章节中看到提供了许多方法来解决
46、这种情况,其中有许多是web平台中常见的(session变量,cookies,和应用变量),比如一些.net的特殊技术,例如中配置管理API。 是一个无状态的协议web开发另一个明显区别于传统桌面程序的是: 是一个无状态的协议,当web服务器对客户端做出响应时,所有早期的联系都结束。这当然不是一个传统的桌面应用程序,它执行的状态一直是变化的,直到用户关闭正在使用的程序。从这一点上来说,作为网络开发者,由你来制定具体的步骤来“存储”那些当前登陆到你网站的用户信息(例如购物手推车中的列表项,信用卡号,家庭和工作地址等)。你将在第33章节中看到提供了许多方法来解决这种情况,其中有许多是web平台中常
47、见的(session变量,cookies,和应用变量),比如一些.net的特殊技术,例如中配置管理API。一个web的应用程序可以被理解为是一个文件的集合(*.htm,*.asp,*.aspx,图像文件,基于XML的文件等)以及相关的组件(例如.net代码库或者传统的COM服务器),它们存储着给定网络服务器中的详细目录。如第33节所示,网络应用程序有特殊的生命周期,并提供了许多事件(例如初始化启动或者最终关闭),你可以通过你的网站运行来连接,以达到执行专业的数据处理。网络服务器是一个负责组织网络应用程序的软件产品,它通常提供一些相关服务,例如集成安全,文件传输协议支持(FTP),邮件交换服务等
48、。互联网信息服务(IIS)是微软的企业级网络服务器产品,正如你所想,它为经典ASP以及ASP.net网络应用程序提供内部支持。应用程序时,你需要经常与IIS交互。要注意的是,当你安装windows操作系统时,IIS并不像其他安装选项一样会被自动被选定(还要注意并非所有的windows版本都支持IIS,比如说windows XP家庭版)。因此,根据你开发环境的配置,你可能希望在开始这一章节之前就安装好了IIS。所以,只要在控制面板中进入添加/删除应用程序,选择添加/删除windows组件即可。如果你需要更多的细节可以参考windows的帮助系统。注意:理想情况是,在安装Visual Studio
49、 2008之前,你的开发环境上已经安装了IIS。如果你在安装Visual Studio 2008之后安装IIS,你的ASP.net网络应用程序将不能正确执行(你将经常得到一个空白网页)。幸运的是,你可以重新配置IIS来支持.net应用程序,主要是通过运行命令行工具以及制定/i选项。如果你的工作环境已正常安装了IIS,你可以在管理工具(在控制面板中)中双击网络信息服务(IIS)应用程序来使用IIS。本章节的目的是:你要关注下面默认的网站节点(如图31-2所示)图31-2 IIS小程序IIS虚拟目录的作用一个IIS配置可以支持很多web应用程序,这些应用程序都在虚拟目录中。每一个虚拟目录都被映射到
50、硬盘的物理路径中。所以,如果你创建了一个叫做CarsRUs的虚拟目录,外界可以使用像这样的URL来定位到这个站点(前提是你站点的IP地址在网络上要被注册)。然后,这个虚拟目录就映射到了网络服务器的物理根目录下,例如C:inetpubwwwrootAspNetCarsSite,它就包含了CarsRUs网络应用程序的内容。在本章节的后面我们会发现,当你使用Visual Studio 2008来创建一个ASP.网络应用程序时,你可以选择通过IDE来为当前站点自动生成新的虚拟目录。如果需要,你也可以手动创建一个虚拟目录,通过右键单击IIS的默认站点,再选择新的虚拟路径(或者在vista上直接添加虚拟目录)。当你选择了创建新虚拟目录的选项时,会被提示输入名称和包含网页内容的物理文件夹。为了说明IIS的使用(也为了建立我们的第一个网页例子),我们在你的硬盘上创建了一个目录,它将储存将要生成的web内容。我们假设这个目录是C:CodeTestsCarsWebSite。现在,右
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 数字化转型下D公司保险业务系统运维项目质量管理的多维剖析与策略构建
- 数字化转型下A银行南宁分行中小企业信贷风险管理创新与实践
- 数字化赋能:高中电磁学演示实验教学革新与实践探索
- 数字化赋能:某省产品质量监督管理系统的创新设计与实践
- 数字化赋能:四川省金玉融资担保有限公司人事管理系统的深度设计与高效实现
- 2025年教师资格之幼儿保教知识与能力练习题库含答案
- 数字化浪潮下:广东省梅州市初中班主任QQ学生管理模式的探索与革新
- 数字化浪潮下区域性中小商业银行经营绩效提升路径探究
- 数字化浪潮下PJ电信农村移动业务市场的营销策略:洞察与突破
- Axure网站与App原型设计(全彩慕课版)(AxureRP10)- 教案 第7-12章 用Axure链接动作制作交互效果-产品经理的职能
- GB/T 25085.5-2026道路车辆汽车电缆第5部分:交流600 V或直流900 V和交流1 000 V或直流1 500 V单芯铜导体电缆的尺寸和要求
- 2026黑龙江省住房和城乡建设厅直属事业单位招聘14人笔试备考试题及答案解析
- 2026年矿山生态修复与矿区治理(新标准陆续实施)
- 2026年安徽工商职业学院单招综合素质考试题库及答案详解(名校卷)
- 2026年山西经贸职业学院单招职业适应性考试题库带答案详解(巩固)
- 2026年安徽城市管理职业学院单招职业适应性测试题库附参考答案详解(突破训练)
- 足疗店内部管理相关规定制度
- 北中医毕业论文
- 穴位贴敷治疗呼吸系统疾病
- (2023-2025)重庆市中考历史高频考点分析及2026备考建议
- 课程与教学论知到智慧树期末考试答案题库2025年浙江师范大学
评论
0/150
提交评论