Friday, June 5, 2026 Sign InRegister FREE My Account Help
FDN Portal
FDN » ASP & VBScript » ASP Fundamentals

ASP Fundamentals

ASP Fundamentals

Active Server Pages (ASP) is Microsoft's server-side scripting technology for building dynamic web pages. ASP code runs on the web server (IIS) and generates HTML sent to the browser.

ASP File Structure

ASP files use the .asp extension. Server-side code is enclosed in <% %> delimiters:

<%@ Language="VBScript" %>
<!DOCTYPE html>
<html>
<head><title>My First ASP Page</title></head>
<body>
  <h1>Hello, World!</h1>
  <p>The current date and time is: <%= Now() %></p>
  <p>Your IP address is: <%= Request.ServerVariables("REMOTE_ADDR") %></p>
</body>
</html>

Built-in Objects

ObjectPurposeExample
RequestRead data from the client (form data, query strings, cookies, headers)Request.Form("username")
ResponseSend data to the client (HTML, cookies, redirects)Response.Write "Hello"
ServerServer utility methods (path mapping, COM object creation, encoding)Server.CreateObject("ADODB.Connection")
SessionPer-user state that persists across requests (20 min default timeout)Session("UserID") = 42
ApplicationApplication-wide state shared by all usersApplication("VisitCount")

Request Object Examples

<%
' Query string: page.asp?id=5&name=John
Dim strID, strName
strID   = Request.QueryString("id")
strName = Request.QueryString("name")

' Form data (POST)
Dim strUsername, strPassword
strUsername = Request.Form("username")
strPassword = Request.Form("password")

' Cookies
Dim strTheme
strTheme = Request.Cookies("theme")

' Server variables
Dim strMethod, strUserAgent
strMethod    = Request.ServerVariables("REQUEST_METHOD")
strUserAgent = Request.ServerVariables("HTTP_USER_AGENT")
%>

Response Object Examples

<%
' Write output
Response.Write "<p>Welcome, " & Server.HTMLEncode(strName) & "</p>"

' Set a cookie
Response.Cookies("theme") = "classic"
Response.Cookies("theme").Expires = DateAdd("d", 30, Now())

' Redirect
Response.Redirect "login.asp"

' Set content type
Response.ContentType = "application/json"
%>
« Previous Server-Side Form Validation
Next » VBScript Language Reference
More in ASP & VBScript
« Back to ASP & VBScript « Back to FDN
FlameNet Weekly: the best of the forum, freshest listings, top Q&A — delivered every Sunday.
13 members · 0 new today · 0 online now · 764 posts in last 24h