Active Server Pages

ASP has other meanings. See its disambiguation page.

Active Server Pages (ASP) is Microsoft's server-side technology for dynamically-generated web pages that is marketed as an add-on to Internet Information Services (IIS).

Programming ASP websites is made easier by various built-in objects. Each object corresponds to a group of frequently-used functionality useful for creating dynamic web pages. In ASP 3.0 there are six such built-in objects: Application, ASPError, Request, Response, Server and Session. Session, for example, is a cookie-based session object that maintains variables from page to page. Application Test Center is also available for load testing.

Most ASP pages are written in VBScript. Other scripting languages can be selected by using the @Language directive. JScript (Microsoft's implementation of JavaScript) is the other language that is usually available. PerlScript (Perl) and others are available as third-party add-ons.

Versions

ASP has gone through four major releases:

  • ASP 1.0 (distributed with IIS 3.0) in December 1996,
  • ASP 2.0 (distributed with IIS 4.0) in September 1997,
  • ASP 3.0 (distributed with IIS 5.0), and
  • ASP.NET (part of the Microsoft .NET platform). The pre-.NET versions are currently referred to as "classic" ASP.
  • ASP.NET2

ASP.NET introduced the ability to replace in-HTML scripting with full-fledged support for .NET languages such as Visual Basic .NET and C#. In-page scripting can still be used (and is fully supported), but now pages can use VB.NET and C# classes to generate pages instead of code in HTML pages.

Examples

Pages can be generated by mixing server-side scripting code (including database access) with HTML and client-side code. For example:

Code:

<%
' This line does nothing, it's just a comment; the next line does:

Response.Write("Wikipedia") ' This code writes out "Wikipedia" to the browser.

%>

Code:

<% 
' No way of changing the value of X.
Dim X     ' Make sure to always Dim your variables.

X = 1     ' X is our variable in this example.

If X = 1 Then
%>

<b>X equals one.</b>

<% Else %>

<b>X is not one.</b>

<% End If %>

The code between the <% ... %> delimiters will be processed by the server. The resulting HTML is <b>X equals one</b> when the server-side variable X = 1.

For more efficiency, it is best not to open and close asp tags <% %> often, as this causes the ASP engine to have to turn on and off.

  • For example, a more efficient solution would be:
Code:
<%
Dim strWikiPedia

strWikiPedia = "free"

' This example uses pure ASP VBScript to get the job done...

If strWikiPedia = "free" then

   Response.write "Stick around and enjoy without entering in a credit card."

Else

   Response.write "Get out your credit card. Or click a banner."

End If
%>

Now that we have covered "constant variables", lets worry about the request object. The request object is a very interesting one, it can read data from the "query string" or from the "form" that submitted to it. But for that you need to understand the difference between "post" and "get". "get" places the variables into the querystring (Request.QueryString()). "post" places the variables into the form (Request.Form()) here is an example.

Code:

<form action="pagename.asp" method="get">
   <input type="text" name="Name" /><br />
   <input type="Submit" />
</form>
<%
' This line does nothing, it's just a comment; the next line does:
strName = request.querystring("Name")

If strName <> "" Then ' If the variable "strName" is not equal to "" (nothing) then

   ' The next line writes out "Welcome to Wikipedia",
   ' then the name of the person, to the browser.

   Response.write "Welcome to Wikipedia " & strName

   ' Important note: In the line above you will notice
   ' there is an extra space in the string, that makes
   ' sure that the name and the string don't get run
   ' together.

End If
%>

That code will ask for your name, when you press "Submit" it will reload the page and display your name, then welcome you to Wikipedia.

External links

Template:Book

de:Active Server Pages es:Active Server Pages fi:ASP fr:Active server pages it:Active Server Pages he:ASP nl:Active Server Pages ja:Active Server Pages no:Active Server Pages pt:ASP ru:ASP sv:Active Server Pages tr:ASP zh:Active Server Pages

Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools