1、外文资ASP3.0&IIS5.0newCharacteristicOneofthemostexcitingnewfeaturesinASP3.0andIIS5.0isroductionprogrammableserversideredirection.Whatthismeanst,finally,wecantransfercontrolexecutionofapagetovingtobother外文资ASP3.0&IIS5.0newCharacteristicOneofthemostexcitingnewfeaturesin
2、ASP3.0andIIS5.0isroductionprogrammableserversideredirection.Whatthismeanst,finally,wecantransfercontrolexecutionofapagetovingtobotherthentbyusingWellseewhatwemeanbythisTheProblemswithnt-sideASPprogrammersregularlyusetheResponse.Redirectementtoloadadifferentpagethet
3、iscurrentlyexecuting.However,manydonttthisdoesntcausetheservertoyloadandexecutethege.WhatitactuallydoesisaddHTTPredirectionheadertotheoutputstreambeingsentfromtheWebservertotheThisheaderlookssomethinglikeHTTP/1.1302ObjectLocationThestandardHTTPushisheader,302Objectls
4、thetresourcetheyrequestedhasmoved.TheLocationrovidestheaddressofthetheywant.coursethisvetobetherealitywhatngisfoolingtheotpagetheywantcanbefoundatadifferentlocation.Whatishappeningtourserverexecutingthepagetheyrequested,butlingtpagetheysmoved.Thi
5、siswhywehavetoexecutetheRedirectmethodbeforeweanypagecontenttotheWhenabrowserreceivesthe302ObjectMovedmessageitrespondsbycancelingtherequestandsendinganewrequestforthepageheLocationvalue.ThisworksinthesamewayaswhenweuseaMETAHTTP-EQUIVhesectionofthepagetheHTTP
6、headershownrisequivalentSotheredirectionisactuallyhappeningonthent,notonourserver.Whilethisgenerallyaproblem,itcancausespuriousmessagestobedisplayedifthereisaproxyserveruseatthentendoftheconnection.Theproxyserverwillercepttheusandmayitselfgeneratea
7、tissentontothetmadetheoriginalrequest.ThiswhytheubiquitousandannoyingTheobjectyourequestedhasbeenmovedandcanbefoundhereisoftendisplayedonntwhenandmayitselfgenerateatissentontothetmadetheoriginalrequest.ThiswhytheubiquitousandannoyingTheobjectyoureques
8、tedhasbeenmovedandcanbefoundhereisoftendisplayedonntwhenweuseResponse.Redirect,althoughproperuseofbufferingcanusuallypreventWhenyouuseResponse.RedirectS4orr,youshouldalwaysturnonbufferingthetopofyourASPpageandthencallResponse.Clearbeforeexecutingthemethod.Of
9、course,withpagebufferingbeingturnedonbydefaultinASP3.0,thisisnotsuchie.AslongasyouuseResponse.Clearbeforeexecutingtheement,nopreviouslyoutputwillbesenttotheServer-sideRedirectioninASPInASP3.0andIIS5.0,wecanavoidtheneedtousent-sideredirectioninalmostallbytakingadvantag
10、eofthetwonewServerobjectmethods:ExecuteandTransfer.Theycontroltobepassedytoage,whichcanbeanASPscriptpageoranyresourcesuchasanHTMLpage,zipfile,orothertypeofThedifferencenthemttheExecutemethodcallstheage,muchlikecallasubroutineorfunctioninourscriptcode.
11、Whentheageorresourcehasexecutionorstreamingtothent,controlpassesbacktotheementfollowingthecalltoExecuteheoriginalpage,andexecutioncontinuesfromthere.WhenweuseTransfermethod,controldoesnotpassbacktotheoriginalpage,andexecutionstopsthepageorresourcewetransferred
12、controlWhatmakesthetwomethodsevenmoreusefultthecurrentpagescontextpassedtopageorresource.ThisincludesthevaluesofallthevariablesinallrinsicASPobjects,suchasthecollectionsoftheRequest,Responseandobjects,andtheirproperties.TheApplicationcontextisalsotransferred,evenifthepage
13、iswithinadifferentvirtualTheresultofallthistthebrowsertitsstillreceivingtheoriginalpage.snotanythingunusualisgoingonatourserver.ItsAddressbarstillshowsthesameand(bestofall)theBack,ForwardandRefreshbuttonsworknormally.Whenweusent-redirection,llynHTMLMETAele
14、ment,thisisntusuallythePartofthetistransferredtothegeorresourceisanyexistinge.Whilewearentgoingtolookationsindetailuntilalaterchapter,itsmentioninghere.ThecurrentpagescontextisencapsulatedwiththeASPObjectContextwhichwediscussedinChapter1.Ifweneedto
15、workwiththise.Whilewearentgoingtolookationsindetailuntilalaterchapter,itsmentioninghere.ThecurrentpagescontextisencapsulatedwiththeASPObjectContextwhichwediscussedinChapter1.Ifweneedtoworkwiththisobjectaspartofanion,wecanuseithetwetransfercontrolWha
16、tareScriptingAnobjectisbasicallyawayofunderstandinghowthevariouspartsofthesystemTheASPobjectprovidesatwecanusetomanipulatetheheHTTPrequestsandresponses,andtheASPenvironmentasawhole.Forwesawhowwecanfindoutthevaluesofssentfromthebrowserbyscollection
17、,whichispartoftheASPRequestThescriptinglanguagesweusealsohaveanobject.However,thisisfortthescriptinglanguagesprovide,asedtotheobjectslikeRequestandtareprovideddirectlybytheASPDLL.ThescriptingobjectsareprovidedbyScriptingRuntimeLibrary(scrrun.dll),whichi
18、sinstalledwiththedefaultActiveScriptingprovidesthreemainobjectsaspartoftheScriptingRuntimeTheDictionaryobjectprovidesausefulstoragetwecanusetostoresedandreferencedbytheirnamenbyindex,aswouldbethecaseinanormalForle,itsidealforstoringthename/valuetweretrievefromtheAS
19、PTheFileSystemObjectobjectprovidesuscstotheunderlyingfilesystemonserver(oronthentinIE5whenusedinconjunctionwithaltypeofpagenamedHypertextApplicationorHTA).WecanusetheFileSystemObjectobjecttoiteratethroughmachineslocalandnetworkeddrives,foldersandTheTextStr
20、eamobjectprovidesstofilesstoredondisk,andisusedinconjunctiontheFileSystemObjectobject.Itcanreadfromorwritetotext(sequential)files.ItcanonlyinstantiatedviatheFileSystemObjectobject,soyoumightprefertothinkofitasachildTheASPServerobjectisdesignedtoprovidethefeat
21、uresweneedtocreatethesecomponentsandapplications,twecanusethemtoextendthecapabilitiesofourscripts.ItdoesthisbyimplementingaloftheCreateObjectmethod.WellseethisisrequiredCreatingObjectinVBScriptandInVisualBasicorVisualthesecomponentsandapplications,twecanuset
22、hemtoextendthecapabilitiesofourscripts.ItdoesthisbyimplementingaloftheCreateObjectmethod.WellseethisisrequiredCreatingObjectinVBScriptandInVisualBasicorVisualBasicforApplications(VBA),wecancreateofobjectsavarietyofways.WecanusetheNewkeywordtocreateanewobjectofthetypeDimHoweve
23、r,thissibleinASPwithVBScriptorJScript,becausethesescriptingdontimplementy.WecantdeclareavariableasbeingofanyspecificypeareallVariantsoranequivalenttype(dependingonthescriptinglanguageinternativeinVisualBasicandVBAistheuseofericmethods.TheCreateObjectmethodtakesasits
24、argumentaor(moreusually)astring,andreturnsanewobjecttSetobjNewObject=TheGetObjectmethodisnormallyusedwhenwehaveofaspecifictype,andwanttocreateaninstanceofantcanhandlethistype:SetobjExcel=Wesospecifythetypeoftwewantaswellasafilename,whichisusefulwehaveseveraltcantSetobj
25、Excel=GetObject(C:myfilessales.xlw,VBScriptsupportsCreateObjectandGetObject.sgetObject,whichworkslikeVBScript.JScriptalsoimplementsathesamewayastheCreateObjectmethod,namedActiveXObject.HoweverthisisusedinconjunctionwiththenewobjNewObject=newWiththeexceptionoftheVisualBasicNewkeyword,whichisntsupportedinVBScriptJScript,wecanuseallthesetechniquestocreateofobjectswithinanASPHowever,candoesnt