外文文獻(xiàn)—ASP3.0和IIS5.0的新特性_第1頁
外文文獻(xiàn)—ASP3.0和IIS5.0的新特性_第2頁
外文文獻(xiàn)—ASP3.0和IIS5.0的新特性_第3頁
外文文獻(xiàn)—ASP3.0和IIS5.0的新特性_第4頁
外文文獻(xiàn)—ASP3.0和IIS5.0的新特性_第5頁
已閱讀5頁,還剩8頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、外文資料asp 3.0 &iis 5.0 new characteristic propertyone of the most exciting new features in asp 3.0 and iis 5.0 is the introduction of programmable serverside redirection. what this means is that, finally, we can transfer control and execution of a page to another one without having to bother the clien

2、t by using response.redirect. well see what we mean by this next.the problems with client-side redirectionasp programmers regularly use the response.redirect statement to load a different page to the one that is currently executing. however, many dont realize that this doesnt automatically cause the

3、 server to immediately load and execute the new page. what it actually does is add an http redirection header to the output stream being sent from the web server to the client. this header looks something like this:http/1.1 302 object movedlocation newpage.aspthe standard http status message in this

4、 header, 302 object moved, tells the browser that the resource they requested has moved. the location header provides the address of the page they want. of course this doesnt have to be the reality what were doing is fooling the browser into thinking that the page they want can be found at a differe

5、nt location. what is actually happening is that our server is executing the page they requested, but is telling them that the page they want has moved. this is why we have to execute the redirect method before we send any page content to the browser.when a browser receives the 302 object moved messa

6、ge it responds by canceling the current request and sending a new request for the page specified in the location value. this works in just the same way as when we use a meta http-equiv tag in the section of the page the http header shown earlier is equivalent to:so the redirection is actually happen

7、ing on the client, not on our server. while this isnt generally a problem, it can cause spurious messages to be displayed if there is a proxy server in use at the client end of the connection. the proxy server will usually intercept the status message and may itself generate a page that is sent on t

8、o the client that made the original request. this is why the ubiquitous and annoying messagethe object you requested has been moved and can be found here is often displayed on the client when we use response.redirect, although proper use of buffering can usually prevent it.when you use response.redi

9、rect in iis 4 or earlier, you should always turn on buffering at the top of your asp page and then call response.clear before executing the response.redirect method. of course, with page buffering being turned on by default in asp3.0, this is not such an issue. as long as you use response.clear befo

10、re executing the statement, no previously generated output will be sent to the client.server-side redirection in asp 3.0in asp 3.0 and iis 5.0, we can avoid the need to use client-side redirection in almost all cases by taking advantage of the two new server object methods: execute and transfer. the

11、y cause control to be passed immediately to another page, which can be an asp script page or any other resource such as an html page, zip file, or other type of file.the difference between them is that the execute method calls the other page, much like we call a subroutine or function in our script

12、code. when the other page or resource has completed execution or streaming to the client, control passes back to the statement following the call to the execute method in the original page, and execution continues from there. when we use the transfer method, control does not pass back to the origina

13、l page, and execution stops at the end of the page or resource we transferred control to.what makes the two methods even more useful is that the current pages context is also passed to the target page or resource. this includes the values of all the variables in all the intrinsic asp objects, such a

14、s the collections of the request, response and session objects, and all their properties. the application objectcontext is also transferred, even if the page is within a different virtual application.the result of all this is that the browser thinks that its still receiving the original page. it has

15、 no idea that anything unusual is going on at our server. its address bar still shows the same url, and (best of all) the back, forward and refresh buttons work normally. when we use client-side redirection, especially with an html meta element, this isnt usually the case.part of the context that is

16、 transferred to the new page or resource is any existing transaction state. while we arent going to look at transactions in detail until a later chapter, its worth mentioning here. the current pages context is encapsulated with the asp objectcontext object, which we discussed in chapter 1. if we nee

17、d to work with this object as part of an ongoing transaction, we can use it within the page that we transfer control to.what are scripting objects?an object model is basically a way of understanding how the various parts of the system are related.the asp object model provides a structure that we can

18、 use to manipulate the different elements in the http requests and responses, and the asp environment as a whole. for example we saw how we can find out the values of any cookies sent from the browser by looking in the cookies collection, which is part of the asp request object.the scripting languag

19、es we use also have an object model. however, this model is for the objects that the scripting languages provide, as opposed to the objects like request and response that are provided directly by the asp dll. the scripting objects are provided by the microsoft scripting runtime library (scrrun.dll),

20、 which is installed with the default active scripting script engines.microsoft provides three main objects as part of the scripting runtime library:the dictionary object provides a useful storage object that we can use to store values, accessed and referenced by their name rather than by index, as w

21、ould be the case in a normal array. for example, its ideal for storing the name/value pairs that we retrieve from the asp request object.the filesystemobject object provides us with access to the underlying file system on the server (or on the client in ie5 when used in conjunction with a special ty

22、pe of page named a hypertext application or hta). we can use the filesystemobject object to iterate through the machines local and networked drives, folders and files.the textstream object provides access to files stored on disk, and is used in conjunction with the filesystemobject object. it can re

23、ad from or write to text (sequential) files. it can only be instantiated via the filesystemobject object, so you might prefer to think of it as a child of that object.the asp server object is designed to provide the features we need to create instances of these components and applications, so that w

24、e can use them to extend the capabilities of our asp scripts. it does this by implementing a special version of the createobject method. well see why this is required next.creating object instances in vbscript and jscriptin visual basic or visual basic for applications (vba), we can create instances

25、 of objects in a variety of ways. we can use the new keyword to create a new object of the type specified:dim objnewobject as new mycomponenthowever, this isnt possible in asp with vbscript or jscript, because these scripting engines dont implement data typing. we cant declare a variable as being of

26、 any specific data type they are all variants or an equivalent type (depending on the scripting language in use).an alternative in visual basic and vba is the use of the generic createobject or getobject methods. the createobject method takes as its argument a classid or (more usually) a progid stri

27、ng, and returns a new object of that type:set objnewobject = createobject(adodb.connection)the getobject method is normally used when we have a document of a specific type, and we want to create an instance of an object that can handle this type of document:set objexcel = getobject(c:myfilessales.xl

28、w)we can also specify the type of object that we want as well as a filename, which is useful if we have several objects that can handle that document type:set objexcel = getobject(c:myfilessales.xlw, excel.application)vbscript supports createobject and getobject. jscript has getobject, which works l

29、ike the vbscript version. jscript also implements a function that works in the same way as the vbscript createobject method, named activexobject. however this is used in conjunction with the jscript new operator:objnewobject = new activexobject(this.object);with the exception of the visual basic new

30、 keyword, which isnt supported in vbscript or jscript, we can use all these techniques to create instances of objects within an asp page. however, can doesnt mean should, and in most cases the scripting engine object creation functions should not be used in an asp page.中文翻譯 asp 3.0 和iis 5.0 的新特性1. 客

31、戶端重定向帶來的問題a s p編程人員通常使用response.redirect語句把一個(gè)頁面載入到當(dāng)前正在執(zhí)行的網(wǎng)頁。然而,許多人沒有意識(shí)到這條語句不會(huì)自動(dòng)地使服務(wù)器立即裝入和執(zhí)行新的網(wǎng)頁。其真正做的是把一個(gè)h t t p重定向報(bào)頭(redirection header)增加到由we b服務(wù)器發(fā)送給客戶的輸出流中。這個(gè)報(bào)頭如下:http/1.1 302 object movedlocation newpage.asp在這個(gè)報(bào)頭中的標(biāo)準(zhǔn)h t t p狀態(tài)信息“ 302 object moved”,告知瀏覽器所要求的資源已經(jīng)發(fā)生移動(dòng)。location報(bào)頭提供相應(yīng)的網(wǎng)頁地址。當(dāng)然這個(gè)地址不一定是真

32、實(shí)的,現(xiàn)在正在做的事情就是“欺騙”瀏覽器,使瀏覽器認(rèn)為可在另一個(gè)位置上找到所需要的網(wǎng)頁。實(shí)際發(fā)生的是,服務(wù)器將執(zhí)行所請(qǐng)求的網(wǎng)頁,但是通知瀏覽器需要的網(wǎng)頁已經(jīng)發(fā)生移動(dòng)。這就是在發(fā)送任何頁面的內(nèi)容到瀏覽器之前必須執(zhí)行redirect方法的原因。當(dāng)一個(gè)瀏覽器接受到“ 302 object moved”信息時(shí),中斷當(dāng)前的請(qǐng)求并為location值中指定的網(wǎng)頁發(fā)送一個(gè)新的請(qǐng)求。這與在網(wǎng)頁的段使用一個(gè)m e ta http-equiv標(biāo)記時(shí)的工作方式相同,前面給出的http報(bào)頭還可寫為:代理服務(wù)器在使用的話,可能會(huì)引起顯示虛假消息。代理服務(wù)器通常會(huì)截取該狀態(tài)信息,并且可能產(chǎn)生一個(gè)頁面發(fā)送給提出原始請(qǐng)求的客

33、戶端。這就是在使用response.redirect時(shí),“the object you requested has been moved and can be found here”消息經(jīng)常在客戶機(jī)上顯示的原因,正確地使用緩沖通??梢苑乐惯@個(gè)問題。在iis 4.0或更早的版本中使用response.redirect時(shí),應(yīng)該在a s p網(wǎng)頁的開頭打開緩沖,然后在執(zhí)行response.redirect方法之前調(diào)用response.clear。當(dāng)然,在asp 3.0中網(wǎng)頁緩沖的缺省狀態(tài)為打開,因此這不成問題。只要在執(zhí)行該語句之前使用response.clear,以前產(chǎn)生的輸出將不會(huì)發(fā)送給客戶。2.

34、在asp 3.0中服務(wù)器端的重定向在asp 3.0和iis 5.0中,在幾乎所有情況下,通過使用兩個(gè)新的server對(duì)象方法execute和transfer,可以避免使用客戶端重定向。這兩個(gè)方法使控制立即轉(zhuǎn)到另一個(gè)網(wǎng)頁,該網(wǎng)頁可以是一個(gè)a s p網(wǎng)頁或者是任何其他的資源,例如一個(gè)http網(wǎng)頁、壓縮文件或其他類型的文件。它們之間的不同之處是: execute方法“調(diào)用”另一個(gè)的網(wǎng)頁,與在腳本代碼中調(diào)用一個(gè)子程序或函數(shù)非常相似。當(dāng)另一個(gè)網(wǎng)頁或資源已經(jīng)執(zhí)行完畢或傳送到客戶端時(shí),控制返回到原網(wǎng)頁中調(diào)用execute方法的語句的下一條語句,并繼續(xù)執(zhí)行。而使用transfer方法時(shí),控制不再返回到原頁面中

35、,在控制傳送到的網(wǎng)頁或資源的末尾處,執(zhí)行過程停止。當(dāng)前網(wǎng)頁的環(huán)境也傳送給了目標(biāo)網(wǎng)頁或資源,因此這兩個(gè)方法更有用。網(wǎng)頁環(huán)境包含了原有的a s p對(duì)象中的所有變量的值,例如response.redirect和session對(duì)象的集合以及它們的所有屬性。即使該網(wǎng)頁不在同一個(gè)虛擬應(yīng)用程序中,也將傳送application對(duì)象的環(huán)境。結(jié)果是瀏覽器認(rèn)為它仍在接收原先的頁面,它并不了解服務(wù)器所做的事情。瀏覽器的地址欄一直顯示相同的u r l,并且back、forward和refresh按鈕正常地工作。在使用客戶端重定向時(shí),尤其是使用html meta元素時(shí),情況通常不是這樣的。傳送到新的頁面或資源的環(huán)境包括

36、所有現(xiàn)存的事務(wù)狀態(tài)(transaction state)。當(dāng)前網(wǎng)頁的環(huán)境用a s p的objectcontext對(duì)象(在第1章中已經(jīng)討論過)進(jìn)行封裝。如果需要將這個(gè)對(duì)象作為一個(gè)正在進(jìn)行的事務(wù)的一部分,可以在傳送控制的目的頁面中使用這個(gè)對(duì)象。腳本對(duì)象的定義對(duì)象模型是用來理解系統(tǒng)的各個(gè)部分相互關(guān)系的一種基本手段。a s p對(duì)象模型提供了一種結(jié)構(gòu),用來作為一個(gè)整體操縱http請(qǐng)求、響應(yīng)及a s p環(huán)境中的不同元素。例如,我們已經(jīng)看到,如何通過查看a s p請(qǐng)求對(duì)象的cookie集合,得到來自瀏覽器的任何cookie值。我們使用的腳本語言也有對(duì)象模型。然而,腳本語言提供的這一對(duì)象模型,不同于由asp dll直接提供的對(duì)象模型,腳本對(duì)象是由mircrosoft腳本運(yùn)行期庫(scrrun.dll )提供的,安裝缺省的active scripting腳本引擎時(shí),也安裝了mircrosoft腳本運(yùn)行期庫。作為腳本運(yùn)行期庫的一部分, mircrosoft提供三個(gè)主要的對(duì)象:dictionary對(duì)象提供一個(gè)極為有用的存儲(chǔ)對(duì)象,它用來存儲(chǔ)值,通過對(duì)象的名字而不是其索引進(jìn)行訪問和引用。例如,對(duì)于存儲(chǔ)從asp request對(duì)象中檢索到的名稱/值對(duì),這是非常合適的。filesystemobject對(duì)象提供了對(duì)服務(wù)器底層文件系統(tǒng)的訪問(在客戶端上使用i e 5 . 0,與名為“h

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論