Sei sulla pagina 1di 5

QuickStart

IntroducingASP

Introducing ASP
Learning About ASP and ServerSide Programming
ASPisaWebserverscriptinglanguagefromMicrosoftusedforembeddingdynamic contentintoHTMLWebpages.ASPstandsforActiveServerPages. ASPisaserversidescriptinglanguage.WhatdistinguishesASPfromsomethinglike clientsideJavaScriptisthatthecodeisexecutedontheserver.Thismeansthattheserver executesyourscriptandtranslatesthecontenttoHTMLbeforesendingittoyourWeb browser.Alloftheheavyliftingandcomputingisdoneontheserver. WhenauserlooksatthesourcefortheWebpagecreatedbyyourASPfile,theyhaveno wayofknowingwhat'sgoingonbehindthescenesalltheyseeistheendresult.

Using ASP
ASPisautomaticallyenabledwithalloftheWindowshostingaccountsweoffer.Onceyou activateyourWindowshostingaccount,youcancreateanduploadPHPpages. Ifyou'renotfamiliarwithASPandnotinterestedinwritingyourownprogrammingcode, youcanstilluseASPonWebsitesbydownloadingexistingscriptsandapplicationsand installingthemonyoursite.ThereareamultitudeoffreeASPscriptsandapplications alreadywrittenanddistributedontheInternet. UsingASPandanMSSQLorAccessdatabase,youcancreaterobustWebsitesthat generatecontentandimagesdynamically. BelowisalistofjustsomeofthefeaturesyoucanaddtoyourWebsiteusingASP:
Blogs Guestbooks DiscussionForums MailFunctions PasswordGeneration DatabaseCommunication Auctions Calendars/Planners Games FileManagement Voting/PollingFeatures

Copyright2007

QuickStart

IntroducingASP

What Asp Looks Like


IfyouarefamiliarwithHTML,ASPisastraightforwardlanguagetolearn.Onceyoulearn thebasicsyntax,youcanexploremoreadvancedfeaturesofASP. HereisabasicexampleofwhatASPlookslikeinanHTMLdocument:

<html> <head> <title>ASPExample</title> </head> <body> <% response.write("EverybodylovesanASPscript!") %> </body> </html>

UnlikePerlorC,there'snoneedtowriteaprogramwithalotofcommandstooutput yourHTML.YousimplywriteanHTMLscriptwithsomeembeddedcodetodo something. NoticehowTheASPcodeisenclosedinspecialstartandendtags.Theseallowyouto jumpintoandoutofASPmode.

Your First ASP Page


Thereareseveralgood(oftenfree)ASPeditorsavailableforwritingyourASPcode,but technicallyyoucanuseanytexteditorprogramtowriteanASPfile(e.g.,Notepad, TextEdit).

ToCreateYourFirstASPPage
1. Openyourtexteditor. 2. Typethefollowingcodeintoyourtexteditor:

Copyright2007

QuickStart

IntroducingASP

<html> <head> <title>ASP Test</title> </head> <body> <% response.write("Hello World!") %> </body> </html>

3. Saveyoufileashello.aspandcloseyourtexteditor.IfyouareusingWindows Notepad,makesurethatthethe.aspreplacesthe.txtextensionwhenyou saveyourfile. 4. UploadyournewASPfiletotherootfolderofyourWindowshostingaccount.


5.

UseyourbrowsertoaccessthefilebytypinginyourWebaddressfollowedby /hello.asp/.Forexample,www.yourdomainnamehere.com/hello.asp.

Ifeverythingisconfiguredcorrectly,ASPwillconvertthecodeinbetweenthe<%and%> tagsanddisplaythetextHelloWorldinyourbrowser.

NOTE: Ifyoutriedthisexampleanditdidnotdisplaycorrectlyoryouseethewholefileas text,contactcustomerservice.Remembertouploadyourfiletoyourhostingaccount.If youtrytoviewthisASPfileonyourcomputer,itwillnotwork.Youneedtouploaditontoa WebserverthathasASPrunning.

ThepointoftheexampleistoshowthespecialPHPtagformat.Inthisexampleweused <%toindicatethestartofaASPscript.ThenwewrotetheASPcontentandleftASP modebyaddingtheclosingtag,%>.YoumayjumpinandoutofASPmodeinanHTML filelikethisanywhereyouwant.

Your Second ASP Page


ThereareanumberoffunctionsyoucancallusingASPthatdisplayinformationabout yourWebbrowserorWebserver.

Copyright2007

QuickStart

IntroducingASP

ToUseASPtoGetInformationAboutYourSystem
1. Openyourtexteditor. 2. Typethefollowingcodeintoyourtexteditor:

<html> <head> <title>ASPInformation</title> </head> <body> <p><strong>Youarebrowsingthissitewith:</strong> <%Response.Write(Request.ServerVariables ("http_user_agent"))%></p> <p><strong>YourIPaddressis:</strong> <%Response.Write(Request.ServerVariables("remote_addr"))%></p> <p><strong>TheDNSlookupoftheIPaddressis:</strong> <%Response.Write(Request.ServerVariables("remote_host"))%></p> <p><strong>Themethodusedtocallthepage:</strong> <%Response.Write(Request.ServerVariables ("request_method"))%></p> <p><strong>Theserver'sdomainname:</strong> <%Response.Write(Request.ServerVariables("server_name"))%></p> <p><strong>Theserver'sport:</strong> <%Response.Write(Request.ServerVariables("server_port"))%></p> <p><strong>Theserver'ssoftware:</strong> <%Response.Write(Request.ServerVariables ("server_software"))%></p> </body> </html>

3. Saveyoufileasinfo.aspandcloseyourtexteditor.IfyouareusingWindows Notepad,makesurethatthethe.aspreplacesthe.txtextensionwhenyou saveyourfile.

Copyright2007

QuickStart

IntroducingASP

4. UploadyournewASPfiletotherootfolderofyourhostingaccount. 5. UseyourbrowsertoaccessthefilebytypinginyourWebaddressfollowedby /info.asp/.Forexample,www.yourdomainnamehere.com/info.asp

Ifeverythingisconfiguredcorrectly,ASPwillconvertthecodeinbetweenthe<%and%> tagsanddisplayinformationaboutyourbrowserandserverinyourHTMLpage.5ngASP

AdditionalResources
ThereareanumberofplacesontheInternetwhereyoucanlearnmoreaboutASPand thedifferenttypesofASPWebapplicationsthatyoucanuseonyourWebsite.Herearea fewlinkstogetyoustarted: MicrosoftActiveServerPagesSite W3School'sASPTutorial ASPAlliance

Copyright2007

Potrebbero piacerti anche