ASP Stands for Active Server Pages (ASP), also known as Classic ASP or ASP Classic. ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to b)ild dynamic web sites, web applications, and web services.
ASP Stands for Active Server Pages (ASP), also known as Classic ASP or ASP Classic. ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to b)ild dynamic web sites, web applications, and web services.
ASP Stands for Active Server Pages (ASP), also known as Classic ASP or ASP Classic. ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to b)ild dynamic web sites, web applications, and web services.
CONTENTS What Is ASP? Creating An ASP Document How Does ASP Works? What Is request Obect In ASP !arious "equest #etho$s What Is "es%onse Obects In ASP Summar& 'O!E'( INSTIT)TE O* #ANA+E#ENT NA#E, SA+A" -APOO" "O'' N)#.E", /001233/20 C'ASS, .CA 4 TH Sem5 Sec 6C 7 S).#ITTED TO , 'ect8 "OHIT WHAT IS ASP? ASP Stands for Active Server Pages (ASP), also known as Classic ASP or ASP Classic, was Microsoft's first server-side script engine for dynamically-generated web pages !nitially released as an add-on to !nternet !nformation Services (!!S) via t"e #indows $% &' (ption Pack, it was s)bse*)ently incl)ded as a free component of #indows Server (since t"e initial release of #indows +''' Server) !t "as now been s)perseded by ASP$,% -eveloping f)nctionality in ASP websites is enabled by t"e active scripting engine's s)pport of t"e Component (b.ect Model (C(M), wit" eac" ob.ect providing a related gro)p of fre*)ently-)sed f)nctions and data attrib)tes !n ASP +' t"ere were si/ b)ilt- in ob.ects0 Application, ASP,rror, 1e*)est, 1esponse, Server, and Session ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to b)ild dynamic web sites, web applications and web services !t was first released in 2an)ary +''+ wit" version 3' of t"e $,% 4ramework, and is t"e s)ccessor to Microsoft's Active Server Pages (ASP) tec"nology ASP$,% is b)ilt on t"e Common 5ang)age 1)ntime (C51), allowing programmers to write ASP$,% code )sing any s)pported$,% lang)age %"e ASP$,% S(AP e/tension framework allows ASP$,% components to process S(AP messages Most ASP pages are written in 67Script, b)t any ot"er Active Scripting engine can be selected instead by )sing t"e 85ang)age directive or t"e 9script lang)age:;lang)age; r)nat:;server;< synta/ 2Script (Microsoft's implementation of ,CMAScript) is t"e ot"er lang)age t"at is )s)ally available PerlScript (a derivative of Perl) and ot"ers are available as t"ird-party installable Active Scripting engine CREATING AN ASP DOCUMENT Creating an ASP doc)ment is easy %o begin coding ASP yo) need only two t"ings0 a simple-te/t editor like notepad or %e/tpad or ,ditpl)s and t"e dedication to follow o)r t)torial= $otepad is t"e most basic of simple-te/t editors and yo) will probably code a fair amo)nt of >%M5 wit" it #"en a browser re*)ests an ASP file, !!S passes t"e re*)est file to t"e ASP engine %"e ASP engine reads t"e corresponding ASP file, line by line, and e/ec)tes t"e scripts in t"e file 4inally, t"e ASP file is ret)rned to t"e browser as plain >%M5 format ASP can connect to databases, dynamically format t"e page, e/ec)te statements, and m)c" more ?o) may )se 67Script, 2avaScript, Perl Script, and Pyt"on Script wit"in Active Server Pages, wit" 67Script set as t"e defa)lt scripting lang)age #e recommend t"at yo) )se 67Script as t"is s"o)ld do everyt"ing yo) need and is t"e most commonly )sed %"e appearance of an Active Server Page depends on w"at is viewing it An Active Server Page looks .)st like a normal >%M5 page to t"e #eb browser t"at receives it !f a visitor to yo)r #eb site views t"e so)rce code of an Active Server Page, t"at's w"at t"ey see0 a normal >%M5 page >owever, t"e file located in t"e server looks very different ?o) also see server-side scripts %"is is w"at t"e Active Server Page looks like to t"e #eb server before it is processed and sent in response to a re*)est HOW DOES ASP WORKS? >ow does an asp file, f)ll of calls to t"e ASP intrinsic ob.ects and ot"er components, get translated into an >%M5 page t"at a standard browser can view (and e/ec)te)@ !n fact, t"e process is reasonably simple0 %"e client re*)ests an ASP page by sending an >%%P Aet or Post 1e*)est to t"e server All t"ings being e*)al, one of two t"ings will "appen "ere !f t"e server cannot find t"e file t"en it responds wit" t"e familiar >%%P &'& $ot 4o)nd message !f t"e file is fo)nd, it will be recogniBed as an Active Server Page beca)se of its .asp e/tension and sent to t"e ASP Scripting engine to be parsed (All t"ings not being e*)al, t"en somet"ing )ntoward C like a Server ,rror C may occ)r) %"e Scripting >ost, located in asp.dll, can now do two t"ings0 !f t"is is t"e first ASP page to be sent to t"is client from t"e server, t"is means a new session, and possibly a new application too, "as beg)n and it will c"eck globalasa for anyt"ing to do before it gets to t"e re*)ested page (nce t"at "as been done, or if t"is is not t"e first ASP page t"e client "as re*)ested, t"e "ost t"en e/ec)tes all t"e server- side scripting code in t"e page as delimited by eit"er 9D D< or 9SC1!P% 1E$A%:SERVER> ... <SCRIPT> tags (nce t"is "as been done, t"e engine passes back one of t"ree t"ings0 an error page, an ob.ect moved stat)s code, or an >%M5 page !f eit"er an error page or a correctly-formed >%M5 page is passed back, it is t"en displayed !f t"e ASP page contained a call to 1esponse.1edirect, t"e server will pass back to t"e client t"e >%%P code F'+ telling it t"at t"e page re*)ested "as moved temporarily $ote t"at if response b)ffering "ad previo)sly been set to tr)e, it will seem to t"e client t"at t"e server a)tomatically transferred "im to t"e new location of t"e page !f response b)ffering is set to false, w"ic" is t"e c)rrent ASP defa)lt, t"ey will see an error page telling t"em t"e page t"ey wanted "as moved temporarily W!t "s Request Object In ASP? %"e 1e*)est ob.ect retrieves t"e val)es t"at t"e client browser passed to t"e server d)ring an >%%P re*)est !t is )sed to get information from t"e )ser Esing t"is ob.ect, yo) can dynamically create web pages and perform vario)s server-side actions based on inp)t from t"e )ser #"en we s)rf to an address t"at begins wit" >%%P, t"e server we are visiting treats t"at as an ;>%%P re*)est;G yo) are in fact ;re*)esting; t"at a partic)lar web page is displayed to yo) %"e same applies to any "ttp "yperlinks t"at yo) click A lot more information is being passed back and fort", between yo)r PC and t"e server of t"e site yo)'re visiting, t"an yo) may be aware of %"is c")nk of data is called a ;re*)est ob.ect; Along wit" t"e E15 we "ave re*)ested, information abo)t yo)r browser, !P address, t"e last E15 we visited and more is being sent along wit" o)r re*)est to view a partic)lar web page (n t"e flip side, in addition to t"e web page we re*)ested, t"e server also sends back server-related information in t"e same re*)est ob.ect All t"is data gets passed in t"e >%%P re*)est (aka 1e*)est (b.ect) #"et"er it was posted via an online form yo) filled in or embedded in t"e E15 as name-val)e pairs, it all ends )p in t"e 1e*)est ob.ect >ow does t"at "appen, yo) wonder@ %"at's a "elpf)l feat)re of Microsoft !!S (internet information services), w"ereas systemsHlang)ages s)c" as Eni/HPerl m)st parseHe/tract t"at information man)ally %o make life a little simpler, t"e 1e*)est (b.ect "as several ;collections; A collection is .)st a fancy word for gro)ping, segregating or classifying all of t"e information t"at's being e/c"anged 4or e/ample, inp)t-capable fields on a form t"at is sent via ;met"od:post; end )p in collection ;4orm;, w"ile name-val)e pairs sent in t"e E15 (or from a form sent via ;met"od:get;) end )p in collection ;I)eryString;, etc %"e synta/, collections, properties and met"ods of t"e ASP 1e*)est ob.ect are as follows0 1e*)estJcollectionKpropertyKmet"odL(variable) Collections Co##ect"ons Desc$"pt"on ClientCertificate %"e ClientCertificate collection provides access to t"e certification fields from a re*)est iss)ed by t"e web browser Commonly, it is )sed w"en t"e client is re*)esting sec)re pages t"ro)g" SS5 connection 7efore )sing t"is collection, yo) m)st config)re yo)r #eb server to re*)est client certificates Cookies %"e Cookies collection allows yo) to retrieve t"e val)es of t"e cookies sent in an >%%P re*)est 4orm %"e 4orm collection allows yo) to retrieve t"e data inp)t into an >%M5 form posted to t"e >%%P re*)est body by a form )sing t"e P(S% met"od I)eryString %"e I)eryString collection allows to retrieve t"e val)es of t"e variables in t"e >%%P *)ery string 4or e/ample, it parses t"e val)es sent by a form )sing t"e A,% Met"od %"e I)eryString collection is less capable t"an t"e 4orm collection, since t"ere is a limit to t"e amo)nt of data t"at can be sent in t"e "eader of an >%%P re*)est Server6ariables %"e Server6ariables collection contains t"e val)es of predefined environment variables pl)s all of t"e >%%P "eader val)es sent from t"e client browser to t"e web server Properties P$ope$t"es Desc$"pt"on %otal7ytes %"e %otal7ytes property is a read-only property t"at specifies t"e total n)mber of bytes sent by t"e client in t"e >%%P re*)est body !t is important w"en preparing to read data from t"e re*)est body )sing t"e 7inary1ead met"od of t"e 1e*)est ob.ect Met"ods Metods Desc$"pt"on 7inary1ead %"e 7inary1ead met"od retrieves t"e data sent to t"e server from t"e client as part of a P(S% re*)est and stores it in a SafeArray A SafeArray is a special variant array t"at contains, in addition to its items, t"e n)mber of dimensions in t"e array and t"e )pper bo)nds of t"e array
%ARIOUS RE&UEST METHOD IN ASP 1esponse ob.ect is )sed to re*)est information eit"er from t"e )ser (by means of form) or from t"e server%"ere are many met"ods assigned to itSome of t"em t"at are )sed mostly are0 !" Request'(o$)*+p!$!)ete$+, %"is is )sed to get information passed from a 4(1M wit" t"e met"od of ;P(S%; E#a$ple: 9form name:;formMname; met"od:;post; action:;t"isMpageasp;< 9inp)t type:;te/t; name:;c)stomerMname; val)e:;;< 9inp)t type:;password; name:;c)stomerMpassword; val)e:;;< 9inp)t type:;s)bmit; name:;b)tton; val)e:;S)bmit;< 9Hform< %" Request'que$-st$"n.*+p!$!)ete$+, 7asically,#e will find t"at t"is statement is same as re*)estform(;parameter;) %"e difference is t"at t"is can be obtained not only from 4(1M wit" t"e met"od of ;A,%; b)t also from direct )rl typing E#a$ple: 9form name:;formMname; met"od:;get; action:;t"isMpageasp;< 9inp)t type:;te/t; name:;c)stomerMname; val)e:;;< 9inp)t type:;password; name:;c)stomerMpassword; val)e:;;< 9inp)t type:;s)bmit; name:;b)tton; val)e:;S)bmit;< 9Hform< /, Request'se$0e$0!$"!b#es*+p$ede("ned1se$0e$10!$"!b#e+, Enlike t"e ot"er two above,we donNt "ave to get some val)es first before retrieving server variables All t"ese information are located at server, available for re*)est anytime we need it, s)c" as 4ollows00 a.&ro'ser infor$ation 9D:re*)estservervariables(;>%%PMES,1MAA,$%;)D< (.)ocal IP Address 9D:re*)estservervariables(;5(CA5MA--1;)D< c. *R) 9D:re*)estservervariables(;E15;)D< d Re+,est $et-od 9D:re*)estservervariables(;1,IE,S%MM,%>(-;)D< e. .ile na$e 9D:re*)estservervariables(;SC1!P%M$AM,;)D< RE&UEST O23ECT IN ASP %"e 1esponse ob.ect in ASP is )sed to send o)tp)t to t"e client from t"e web server %"e 1e*)est ob.ect retrieves t"e val)es t"at t"e client browser passed to t"e server d)ring an >%%P re*)est !t is )sed to get information from t"e )ser Esing t"is ob.ect, we can dynamically create web pages and perform vario)s server-side actions based on inp)t from t"e )ser !ts collections, properties, and met"ods are described below0 Co##ect"ons4 Collection -escription Cookies Sets a cookie val)e !f t"e cookie does not e/ist, it will be created, and take t"e val)e t"at is specified P$ope$t"es Property -escription 7)ffer Specifies w"et"er to b)ffer t"e page o)tp)t or not Cac"eControl Sets w"et"er a pro/y server can cac"e t"e o)tp)t generated by ASP or not C"arset Appends t"e name of a c"aracter-set to t"e content-type "eader in t"e 1esponse ob.ect Content%ype Sets t"e >%%P content type for t"e 1esponse ob.ect ,/pires Sets "ow long (in min)tes) a page will be cac"ed on a browser before it e/pires ,/piresAbsol)te Sets a date and time w"en a page cac"ed on a browser will e/pire !sClientConnected !ndicates if t"e client "as disconnected from t"e server Pics Appends a val)e to t"e P!CS label response "eader Stat)s Specifies t"e val)e of t"e stat)s line ret)rned by t"e server Metods Metod Desc$"pt"on Add>eader Adds a new >%%P "eader and a val)e to t"e >%%P response Append%o5og Adds a string to t"e end of t"e server log entry 7inary#rite #rites data directly to t"e o)tp)t wit"o)t any c"aracter conversion Clear Clears any b)ffered >%M5 o)tp)t ,nd Stops processing a script, and ret)rns t"e c)rrent res)lt 4l)s" Sends b)ffered >%M5 o)tp)t immediately 1edirect 1edirects t"e )ser to a different E15 #rite #rites a specified string to t"e o)tp)t 1esponse (b.ect is one of t"e most important ob.ects in ASP !t is t"e ob.ect w"ic" comm)nicates between t"e server and t"e o)tp)t w"ic" is sent to t"e client %o write an ASP page, all we need to do is write a standard >%M5 page, p)tting in t"e Active Server Pages script w"ere needed Active Server Pages script is denoted by t"e te/t between 9D's and D<'s %o send ASP to t"e client,we need to )se t"e 1esponse ob.ect %"e met"od of t"e 1esponse ob.ect w"ic" sends data to t"e client is t"e #rite met"od 4or e/ample, if yo) write an >%M5 page w"ic" looks like0 9D8 5A$AEAA,:;67SC1!P%; D< 9>%M5< 97(-?< 9D 1esponse#rite(;>ello, #orld=;) D< 9H7(-?< 9H>%M5< if a )ser views t"e page wit" a standard browser, t"ey will see t"e te/t, ;>ello, #orld=; on t"e screen !t's as if yo) "ad .)st written an >%M5 page wit" t"e words ;>ello, #orld=; w"ere t"e 9D's t"e te/t between and t"e D<'s were (f co)rse, )nlike an >%M5 page w"ic" is sent directly to t"e client, t"is page "as passed t"ro)g" t"e server's ASP-55, parsing it so t"at instead of t"e client seeing9D 1esponse#rite(;>ello, #orld=;) D<, t"e client merely sees ;>ello, #orld=; ,ven if t"e )ser goes to 6iew So)rce in t"eir browser, t"ey will only see t"e ;>ello, #orld=; %"is is beca)se t"e client is never sent t"e preprocessed ASP script we can in"erently invoke t"e 1esponse#rite met"od by )sing t"e e*)als (:) sign >ere is an e/ample, w"ic" "appens to prod)ce t"e e/act same o)tp)t as above0 9D8 5A$AEAA,:;67SC1!P%; D< 9>%M5< 97(-?< 9D:;>ello, #orld=; D< 9H7(-?< 9H>%M5< As we notice, we .)st got rid of t"e 1esponse#rite( ), b)t left t"e st)ff in between %"e : sim)lates 1esponse#rite %"ere are also a few ot"er neat properties in t"e 1esponse ob.ect (ne is ,/pires, w"ic" sets "ow soon o)r page e/pires Many modern browsers cac"e pages for *)icker downloading times #e can )se ASP to set "ow often t"e browser c"ecks to see if it needs to redownload t"e page ?o) set it in terms on min)tes !f yo) want to browser not to cac"e t"e page, yo) can set 1esponse,/pires : '
SUMMAR5 Active Server Pages (ASP) was Microsoft's first server-side script engine for dynamically-generated web pages !t is also known as Classic ASP or ASP Classic !t "as now been replaced by ASP$,% !t is a server side tec"nology t"at enables )s to make dynamic and interactive web pages t"at are not affected by t"e type of browser t"e web site visitor is )sing %"e 1e*)est ob.ect retrieves t"e val)es t"at t"e client browser passed to t"e server d)ring an >%%P re*)est !t is )sed to get information from t"e )ser Esing t"is ob.ect, yo) can dynamically create web pages and perform vario)s server-side actions based on inp)t from t"e )ser %"e 1esponse ob.ect in ASP is )sed to send o)tp)t to t"e client from t"e web server %"e 1e*)est ob.ect retrieves t"e val)es t"at t"e client browser passed to t"e server d)ring an >%%P re*)est !t is )sed to get information from t"e )ser Esing t"is ob.ect, we can dynamically create web pages and perform vario)s server-side actions based on inp)t from t"e )ser