




已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
WhatisanASPFile?WithASPfiles,youcanactivateyourWebsiteusinganycombinationofHTML,scripting-suchasJavaScriptorVisualBasicScriptingEdition(VBScript)-andcomponentswritteninanylanguage.ThismeansyourASPfileissimplyafilethatcancontainanycombinationofHTML,scripting,andcallstocomponents.WhenyoumakeachangeontheASPfileontheserver,youneedonlysavethechangestothefilethenexttimetheWebpageisloaded,thescriptwillautomaticallybecompiled.Howdoesthishappen?ItworksbecauseASPtechnologyisbuiltdirectlyintoMicrosoftWebservers,andisthussupportedonallMicrosoftWebservers:WindowsNTInternetInformationServer(IIS)3.0,WindowsNTWorkstation,andWindows95PersonalWebServer.TheobjectmodelofASP,MicrosoftstyleHereshowitworks.WhenabrowserrequestsanASPfilefromyourWebserver,yourWebservercallsActiveServerPagestoreadthroughtheASPfile,executinganyofthecommandscontainedwithinandsendingtheresultingHTMLpagetothebrowser.AnASPfilecancontainanycombinationofHTML,script,orcommands.Thescriptcanassignvaluestovariables,requestinformationfromtheserver,orcombineanysetofcommandsintoprocedures.ASPusesthedelimiters(betterknowntoyouandmeasthing-a-ma-bobsthatspecifythebeginningandend)toenclosescriptcommands.Forexample,thecodebelowsetsthevalueofthevariableMyFavTVShowintheusercookiestoIDreamofJeannie.ThescriptinglanguagessupportedbyASPinturnsupportuseoftheIf-Then-Elseconstruct(somethingthatwillundoubtedlywarmtheheartsofallcodersoutthere).Finally,youcanembedsomereallogicintoyourHTML.Forexample,thefollowingcodefromtheIISdocumentationshowshowyoucansetthegreetingshownbaseduponthetimeofday.=#12:00:00AM#AndTimeGoodMorning!Hello!ImsurethatyoucanthinkofsomethingmoreinterestingforyourWebsiteIdhatetohavetocomeupwithallofthecleverideas.Built-inObjectsASPincludesfivestandardobjectsforglobaluse:RequesttogetinformationfromtheuserResponsetosendinformationtotheuserServertocontroltheInternetInformationServerSessiontostoreinformationaboutandchangesettingsfortheuserscurrentWeb-serversessionApplicationtoshareapplication-levelinformationandcontrolsettingsforthelifetimeoftheapplicationTheRequestandResponseobjectscontaincollections(bitsofinformationthatareaccessedinthesameway).Objectsusemethodstodosometypeofprocedure(ifyouknowanyobject-orientedprogramminglanguage,youknowalreadywhatamethodis)andpropertiestostoreanyoftheobjectsattributes(suchascolor,font,orsize).TheRequestobjectTheRequestobjectisusedtogetinformationfromtheuserthatispassedalonginanHTTPrequest.AsImentionedearlier,theRequestandResponseobjectssupportcollections:ClientCertificatetogetthecertificationfieldsfromtherequestissuedbytheWebbrowser.ThefieldsthatyoucanrequestarespecifiedintheX.509standardQueryStringtogettextsuchasaname,suchasmyfavoriteTVsitcomaboveFormtogetdatafromanHTMLformCookiestogetthevalueofapplication-definedcookieServerVariablestogetHTTPinformationsuchastheservernameTheResponseobjectTheResponseobjectisusedtosendinformationtotheuser.TheResponseobjectsupportsonlyCookiesasacollection(tosetcookievalues).TheResponseobjectalsosupportsanumberofpropertiesandmethods.Propertiescurrentlysupportedare:Buffersettobufferpageoutputattheserver.Whenthisissettotrue,theserverwillnotsendaresponseuntilalloftheserverscriptsonthecurrentpagehavebeenprocessed,oruntiltheFlushorEndmethodhasbeencalled.ContentTypetosetthetypeofcontent(i.e:text/HTML,Excel,etc.)Expiressetstheexpiration(whenthedataintheuserscacheforthisWebpageisconsideredinvalid)basedonminutes(i.e.:expiresin10minutes).ExpiresAbsoluteallowsyoutosettheexpirationdatetoanabsolutedateandtime.Statusreturnsthestatusline(definedintheHTTPspecificationfortheserver).ThefollowingmethodsaresupportedbytheResponseobject:AddHeaderAddsanHTMLheaderwithaspecifiedvalueAppendToLogAppendsastringtotheendoftheWebserverlogfileBinaryWritewritesbinarydata(i.e,Excelspreadsheetdata)ClearclearsanybufferedHTMLoutput.Endstopsprocessingofthescript.Flush-sendsalloftheinformationinthebuffer.RedirecttoredirecttheusertoadifferentURLWritetowriteintotheHTMLstream.ThiscanbedonebyusingtheconstructResponse.write(hello)ortheshortcutcommandTheServerobjectTheServerobjectsupportsoneproperty,ScriptTimeout,whichallowsyoutosetthevalueforwhenthescriptprocessingwilltimeout,andthefollowingmethods:CreateObjecttocreateaninstanceofaservercomponent.Thiscomponentcanbeanycomponentthatyouhaveinstalledonyourserver(suchasanActiveX).HTMLEncodetoencodethespecifiedstringinHTML.MapPathtomapthecurrentvirtualpathtoaphysicaldirectorystructure.Youcanthenpassthatpathtoacomponentthatcreatesthespecifieddirectoryorfileontheserver.URLEncodeappliesURLencodingtoaspecifiedstring.TheSessionobjectTheSessionobjectisusedtostoreinformationaboutthecurrentusersWeb-serversession.Variablesstoredwiththisobjectexistaslongastheuserssessionisactive,evenifmorethanoneapplicationisused.Thisobjectsupportsonemethod,Abandon,which(believeitornot!)abandonsthecurrentWeb-serversession,destroyinganyobjects,andsupportstwoproperties,SessionID,containingtheidentifierforthecurrentsession,andTimeout,specifyingatime-outvalueforthesession.Onethingtobearinmindaboutthesessionidentifier:ItsnotaGUID.ItsonlygoodaslongasthecurrentWeb-serversessionisrunning.IfyoushutdowntheWeb-serverservice,theidentifierswillstartalloveragain.SodontuseittocreatelogonIDs,oryoullhaveabunchofduplicatesandoneheckofaheadache.TheApplicationobjectTheApplicationobjectcanstoreinformationthatpersistsfortheentirelifetimeofanapplication(agroupofpageswithacommonroot).Generally,thisisthewholetimethattheIISserverisrunning.Thismakesitagreatplacetostoreinformationthathastoexist
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 内陆养殖市场趋势预测与分析考核试卷
- 化工企业物流成本分析与控制方法考核试卷
- 废气排放考核试卷
- 光学玻璃微观缺陷修复的表面活性剂应用研究考核试卷
- 海洋腐蚀机理分析考核试卷
- 入场三级教育培训考核试卷(含答案)
- 2024年度全科专业基地住培学员对带教师资的评价方案
- 环保知识题库 (一)
- 植树节热身活动方案
- 永生花促销活动方案
- 2024-2025学年度天津铁道职业技术学院单招《语文》真题附答案详解(突破训练)
- 2025年育婴师职业资格考试试题及答案
- 2023年三种人试题附答案
- 北京市八十中学2025届八年级英语第二学期期中经典试题含答案
- 2024年 金泽镇专职村务工作者招录考试真题试题含答案
- 哇哈哈品牌管理制度
- 2025年内蒙古自治区包头市东河区第二中学英语八年级第二学期期末复习检测模拟试题含答案
- 2025年四川省达州市中考英语真题(原卷版)
- 2025-2026年中国台球产业消费趋势报告
- 2024年证券市场基本法律法规真题及答案
- 湖南省2025年高考公安院校公安专业考生档案审核表
评论
0/150
提交评论