版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 外 文 翻 译毕业设计题目: 基于ASP.NET的 物业管理系统开发 原文1: ASP.NET 2.0 Web Pages and Web Controls 译文1: ASP.NET 2.0 网页和Web控件 原文2:The Role of Global.asax File译文2: Global.asax文件的作用 原文1ASP.NET 2.0 Web Pages and Web ControlsUntil now, all of the example applications in this text have focused on console-based and Windows F
2、orms front ends. In this chapter and the next, youll explore how the .NET platform facilitates the construction of browser-based presentation layers. To begin, youll quickly review a number of key web-centric concepts (HTTP, HTML, client-side, and server-side script) and the role of the web server (
3、including the ASP.NET development server, WebDev.WebServer.exe).With this web primer out of the way, the remainder of this chapter concentrates on the composition of ASP.NET (including the enhanced code-behind model) and how to work with ASP.NET web controls. As you will see, ASP.NET 2.0 provides a
4、number of new web controls, a new “master page”model, and various customization techniques.The Role of HTTPWeb applications are very different animals from traditional desktop applications (to say the least).The first obvious difference is that a production-level web application will always involve
5、at least two networked machines (of course, during development it is entirely possible to have a single machine play the role of both client and server). Given this fact, the machines in question must agree upon a particular wire protocol to determine how to send and receive data. The wire protocol
6、that connects the computers in question is the Hypertext Transfer Protocol (HTTP).When a client machine launches a web browser (such as Netscape Navigator, Mozilla Firefox,or Microsoft Internet Explorer), an HTTP request is made to access a particular resource (such as an *.aspx or *.htm file) on th
7、e remote server machine. HTTP is a text-based protocol that is built upon a standard request/response paradigm. For example, if you navigate to www. IntertechT, the browser software leverages a web technology termed Domain Name Service (DNS) that converts the registered URL into a four-pa
8、rt, 32-bit numerical value (aka an IP address). At this point, the browser opens a socket connection (typically via port 80) and sends the HTTP request for the default page at the http:/www.IntertechT website.Once the hosting web server receives the incoming HTTP request, the specified re
9、source may contain logic that scrapes out any client-supplied input values (such as values within a text box) in order to format a proper HTTP response. Web programmers may leverage any number of technologies(CGI, ASP, ASP.NET, Java servlets, etc.) to dynamically generate the content to be emitted i
10、nto the HTTP response. At this point, the client-side browser renders the HTML emitted from the web server. Another aspect of web development that is markedly different from traditional desktop programming is the fact that HTTP is an essentially stateless wire protocol. As soon as the web server emi
11、ts a response to the client, everything about the previous interaction is forgotten. Therefore, as a web developer, it is up to you take specific steps to “remember” information (such as items in a shopping cart) about the clients who are currently logged on to your site. As you will see in the next
12、 chapter, ASP.NET provides numerous ways to handle state, many of which are commonplace to any web platform (session variables, cookies, and application variables) as well as some new techniques (view state, control state, and the cache).Understanding Web Applications and Web ServersA web applicatio
13、n can be understood as a collection of files (*.htm, *.asp, *.aspx, image files, etc.) and related components (such as a .NET code library) stored within a particular set of directories on a given web server. As shown in Chapter 24, web applications have a specific life cycle and provide numerous ev
14、ents (such as initial startup or final shutdown) that you can hook into.A web server is a software product in charge of hosting your web applications, and it typically provides a number of related services such as integrated security, File Transfer Protocol (FTP) support, mail exchange services, and
15、 so forth. Internet Information Server (IIS) is Microsofts enterprise-level web server product, and as you would guess, it has intrinsic support for classic ASP as well as ASP.NET web applications.When you build ASP.NET web applications, you will often need to interact with IIS. Be aware, however, t
16、hat IIS is not automatically selected when you install the Windows Server 2003 or Windows XP Professional Edition (you cant install IIS on the Home editions of Windows). Therefore, depending on the configuration of your development machine, you may be required to manually install IIS before proceedi
17、ng through this chapter. To do so, simply access the Add/Remove Program applet from the Control Panel folder and select Add/Remove Windows Components.Working with IIS Virtual DirectoriesA single IIS installation is able to host numerous web applications, each of which resides in a virtual directory.
18、 Each virtual directory is mapped to a physical directory on the local 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 http:/www.CarsRU (assuming your sites IP address has been registered with the world
19、at large). Under the hood, the virtual directory maps to a physical root directory such as C:inetpubwwwrootAspNetCarsSite, which contains the content of the web application.When you create ASP.NET web applications using Visual Studio 2005, you have the option of generating a new virtual directory fo
20、r the current website. However, you are also able to manually create a virtual directory by hand. For the sake of illustration, assume you wish to create a simple web application named Cars. The first step is to create a new folder on your machine to hold the collection of files that constitute this
21、 new site (e.g., C:CodeTestsCarsWebSite).Next, you need to create a new virtual directory to host the Cars site. Simply right-click the Default Web Site node of IIS and select New Virtual Directory from the context menu. This menu selection launches an integrated wizard. Skip past the welcome screen
22、 and give your website a name (Cars). Next, you are asked to specify the physical folder on your hard drive that contains the various files and images that represent this site (in this case, C:CodeTestsCarsWebSite).The final step of the wizard prompts you for some basic traits about your new virtual
23、 directory (such as read/write access to the files it contains, the ability to view these files from a web browser, the ability to launch executables e.g., CGI applications, etc.). For this example, the default selections are just fine (be aware that you can always modify your selections after runni
24、ng this tool using various right-click Property dialog boxes integrated within IIS).译文1作者:迪诺弗雷国籍:美国出处:ASP.NET 2.0 and Data-Bound ControlsASP.NET 2.0网页和Web控件到现在为止,本书的示例应用程序主要集中在控制台和基于Windows窗体前端。在本章及下面学习中,将探讨如何用.NET平台促进浏览器的建设。首先,你很快就会再次看到关于网络中心的概念(HTTP,HTML格式,客户端和服务器端脚本)和web服务器(包括ASP.NET开发服务器,WebDev.
25、WebServer作用。exe文件)。了这一点,本章的剩余部分主要是ASP网络(包括增强的代码隐藏模型),以及如何使用ASP.NET Web控件和ASP.NET组成。正如你所看到的,ASP.NET 2.0提供了一些新的网络控制模式,新的“母版页”的模式,以及各种定制技术。HTTP的作用Web应用程序不同于传统的桌面应用程序。第一个明显不同的是,产生Web应用程序将至少涉及两台联网的机器(当然在开发过程中完全有可能有一台机器扮演客户端和服务器角色)。鉴于这一事实,机器必须确定一个特定的有线协议,以确定如何发送和接收数据。线路协议,关系到计算机的问题是超文本传递协议(HTTP)。当客户机启动一个(
26、如Netscape Navigator,Mozilla Firefox浏览器,或Microsoft Internet Explorer)浏览器,一个HTTP请求访问(如*. aspx或*. htm文件)在远程服务器上的特定资源。 HTTP是一个基于文本的协议,是建立在一个标准的请求/响应式。例如,如果导航到http:/www.IntertechT,浏览器软件利用网络技术网域名称服务(DNS)转换成由四个部分组成,32位数值(又名IP地址)注册的网址。此时,浏览器打开一个(通常是通过端口80)套接字连接和发送的默认HTTP网页上http:/www.IntertechTrai
27、要求。一旦托管的Web服务器接收 发送来的HTTP请求,指定的资源可能包含逻辑输入值(例如在一个文本框的值),以便以适当的格式回复HTTP响应。 Web程序员可以利用任何技术(共同闸道介面,的ASP,ASP.NET,Java Servlets和等)来动态生成纳入HTTP响应的内容。此时,客户端的HTML浏览器从Web服务器发出的请求。网络的另一个显着的发展是从传统的桌面程序变成HTTP的无国界有线协议。只要服务器发出响应客户,所有关于以前的交互作用被遗忘了。因此,作为Web开发人员,它是由你采取具体步骤,以“记住”信息(如在购物车中的物品)有关目前谁登录到您的站点。你会在下一章
28、看到,ASP.NET提供了许多方法来处理状态,其中许多是很常见网络平台(会话变量,Cookie和应用程序变量)以及一些新技术(视图状态,控制状态,和缓存)。了解Web应用程序和Web服务器一个web应用程序可以被理解为一个档案集合(*.热媒,*. asp和*.的ASPX,图像文件等)和(如相关的组件。NET代码库)在一组特定的目录中存储给定的Web服务器。如第24章所示,Web应用程序有一个特定的生命周期,并提供了许多活动(如初始启动或最后关闭),可以连接到。Web服务器是 接管网络应用的软件产品,而且通常提供集成安全等一系列相关服务的数量,文件传输协议(FTP)的支持,邮件交换服务,等等。互
29、联网信息服务(IIS)是微软的企业级Web服务器的产品,它内在的支持传统的ASP以及ASP.NET Web应用程序。当你建立ASP.NET Web应用程序,你会经常需要与IIS进行交互。请注意,IIS是不会自动选择安装Windows Server 2003或Windows XP专业版(无法安装在Windows家用版IIS)的。因此,在你的开发机器配置不同时,您可能需要手动安装本章所说的IIS程序。为此,只需访问添加/从控制面板文件夹删除程序小程序并选择添加/删除Windows组件。工作与IIS虚拟目录在每一个虚拟目录里单一的IIS有能力办好许多Web应用程序。每一个虚拟目录映射到本地硬盘驱动器
30、的物理目录。因此,如果您创建一个新的虚拟目录名为CarsRUs,外界可以浏览到这个网站使用的网址,如http:/www.CarsRU(假设您的网站的IP地址已经与整个世界的登记)。在内部,该虚拟目录映射到一个物理根目录,如C: inetpub wwwroot的 AspNetCarsSite,其中包含Web应用程序的内容。当您创建ASP.NET Web应用程序使用Visual Studio 2005,您可以产生一个新的当前网站的虚拟目录选项。不过,你也可以手动创建一个虚拟目录。为了说明起见,假设你想创建一个简单的Web应用程序命名为汽车。第一步是创建一个你新文件夹以保存文件,构成新的网
31、站(例如,C: CodeTests CarsWebSite)集合。下面,需要创建一个新的虚拟目录举办汽车的网站。只需右键单击默认Web站点的IIS节点,然后从上下文菜单中选择New虚拟目录。此菜单选择启动一个综合向导。跳过过去的欢迎屏幕,是你的网站的名称(汽车)。接下来,您被要求指定您的硬盘驱动器包含各种文件和图像的物理文件夹代表本网站(在此情况下,C: CodeTests CarsWebSite)。在向导的最后一步会提示你新的虚拟目录(如读/写访问的文件它包含了一些基本特征你,能够从一个网页浏览器这些文件,能够发射可执行文件例如,共同闸道介面应用等)。在这个例子中,只是默认选择(注意,您可以
32、随时修改运行此工具后,使用不同的用鼠标右键单击属性对话框在IIS集成箱您的选择)。 原文2The Role of the Global.asax FileAt this point, an ASP.NET application may seem to be little more than a set of *.aspx files and their respective web controls. While you could build a web application by simply linking a set of related web pages, you will m
33、ost likely need a way to interact with the web application as a whole. To this end, your ASP.NET web applications may choose to include an optional Global.asax file via the WebSite.Add New Item menu option.Simply put, Global.asax is just about as close to a traditional double-clickable *.exe that we
34、 can get in the world of ASP.NET, meaning this type represents the runtime behavior of the website itself. Once you insert a Global.asax file into a web project, you will notice it is little more than a block containing a set of event handlers:void Application_Start(Object sender, EventArgs e)/ Code
35、 that runs on application startupvoid Application_End(Object sender, EventArgs e)/ Code that runs on application shutdownvoid Application_Error(Object sender, EventArgs e)/ Code that runs when an unhandled error occursvoid Session_Start(Object sender, EventArgs e)/ Code that runs when a new session
36、is startedvoid Session_End(Object sender, EventArgs e)/ Code that runs when a session endsLooks can be deceiving, however. At runtime, the code within this block is assembled into a class type deriving from System.Web.HttpApplication. If you have a background in ASP.NET 1.x, you may recall that the
37、Global.asax code-behind file literally did define a class deriving from HttpApplication.The Global Last Chance Exception Event Handler First, let me point out the role of the Application_Error() event handler. Recall that a specific page may handle the Error event to process any unhandled exception
38、that occurred within the scope of the page itself. In a similar light, the Application_Error() event handler is the final place to handle an exception that was not handled by a specific page. As with the page-level Error event, you are able to access the specific System.Exception using the inherited
39、 Server property: void Application_Error(Object sender, EventArgs e)Exception ex = Server.GetLastError();Response.Write(ex.Message);Server.ClearError();Given that the Application_Error() event handler is the last chance exception handler for your web application, odds are that you would rather not r
40、eport the error to the user, but you would like to log this information to the web servers event log, for example:.void Application_Error(Object sender, EventArgs e)/ Log last error to event log.Exception ex = Server.GetLastError();EventLog ev = new EventLog(Application);ev.WriteEntry(ex.Message, Ev
41、entLogEntryType.Error);Server.ClearError();Response.Write(This app has bombed. Sorry!);The HttpApplication Base Class As mentioned, the Global.asax script is dynamically generated into a class deriving from the System.Web.HttpApplication base class, which supplies the same sort of functionality as t
42、he System.Web.UI.Page type.Application This property allows you to interact with application-level variables, using the exposed HttpApplicationState type.Request This property allows you to interact with the incoming HTTP request (via HttpRequest).Response This property allows you to interact with t
43、he incoming HTTP response (via HttpResponse).Server This property gets the intrinsic server object for the current request (via HttpServerUtility).Session This property allows you to interact with session-level variables, using the exposed HttpSessionState type.译文2作者:P.S.Yu, H.Heiss, and D.M.Dias国籍:
44、德国出处:ASP.NET 2.0 Web Pages and Web ControlsGlobal.asax文件的作用ASP.NET应用程序看起来是一个*. aspx文件中各自的网络控制设置。虽然可以通过建立起来的相关网页设置一个Web应用程序,你很可能需要一种整个互动的Web应用程序。为此,ASP.NET Web应用程序可以通过选择一个可选的Global.asax网站添加新项菜单选项文件。简单地说,Global.asax是一种类似于传统的double-clickable *.exe文件,在ASP.NET世界,这意味着这种类型的网站代表了本身运行时的行为。一旦你插入的一个Global.asax文件转换成一个网页专题研究,你会发现它是包含一组事件处理器:void Application_Start(Object sender, EventArgs e)/ Code that runs on application startupvo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 校园教学楼光伏发电系统安装合同
- 2025合同审核管理制度
- 2025装修公司合同样本超市特许合同样本
- 贸易信息Internet推广合作合同
- 2025演艺器材租赁合同
- 2025保温合同(久安)-合同协议-表格模板-应用文书
- 仓储库存周转率的优化方法
- 小寒节气生活讲解模板
- 拼多多运营述职报告
- 室内空气治理技术培训
- 质量员之设备安装质量基础知识通关题库带答案
- 散装油实名登记治安管理信息系统汇报专题培训课件
- 乡土中国知识点汇总 统编版高中语文必修上册
- 车辆模型介绍
- 《介入放射学》考试复习题库及答案
- 母牛的生殖生理
- C语言程序设计基础知到章节答案智慧树2023年石河子大学
- (三级高级)采购员职业资格考试重点复习题库(500题)
- 顶尖课课练(学生版)数学七年级上整理版2020.11.30
- 高大模板工程安全技术交底
- 山景系列产品包发布1-入门和选型ap8248a2数据手册prelimiary
评论
0/150
提交评论