Chapter 45: ASP Response Object

1. What is the Response Object?

The Response object is the server’s mouthpiece — everything you want to send to the browser (HTML, headers, cookies, redirects, status codes, content type, etc.) goes through the Response object.

In simple words:

  • Request = what the browser sends to the server
  • Response = what the server sends back to the browser

Without Response, your ASP page would do calculations silently and send nothing to the user.

2. The Most Important Response Methods & Properties

Here are the ones you will use every single day in Classic ASP — ranked by how often you actually wrote them in real code.

Method / Property What it does Real-world frequency Example
Response.Write Sends text/HTML to the browser ★★★★★ (most used) Response.Write “<p>Hello</p>”
<%= expression %> Shortcut for Response.Write expression ★★★★★ <%= Now() %>
Response.Redirect Sends 302 redirect to browser ★★★★☆ Response.Redirect “login.asp”
Response.Cookies(“key”) = value Sets a cookie ★★★★☆ Response.Cookies(“User”) = “Rahul”
Response.End Stops processing and sends what has been written ★★★☆☆ After error or redirect
Response.Flush Sends buffered content immediately ★★☆☆☆ Long pages / progress feedback
Response.Buffer = True/False Turns buffering on/off (default True) ★★☆☆☆ Response.Buffer = False for streaming
Response.ContentType Sets MIME type (text/html, application/json, etc.) ★★☆☆☆ Response.ContentType = “application/json”
Response.Status Sets HTTP status code ★☆☆☆☆ Response.Status = “404 Not Found”
Response.AddHeader Adds custom HTTP header ★☆☆☆☆ Response.AddHeader “X-Custom”, “value”

3. Basic Example 1 – Hello World with Response.Write

asp

Important:

  • <%= Now() %> = exactly the same as <% Response.Write Now() %>
  • Always use Server.HTMLEncode for user-controlled data

4. Example 2 – Form Processing + Response.Redirect

asp

dashboard.asp (protected page)

asp

5. Example 3 – JSON API Endpoint with Response.ContentType

Very common in late Classic ASP sites that added AJAX.

asp

→ Browser gets pure JSON → jQuery / JavaScript can parse it easily.

6. Example 4 – Forcing Download (Content-Type + AddHeader)

asp

7. Teacher Summary – ASP Response Object in Classic ASP

ASP Response Object is the server’s way to talk back to the browser:

  • Response.Write / <%= … %> → send text/HTML
  • Response.Redirect → 302 redirect (very common)
  • Response.Cookies → set cookies
  • Response.ContentType → change MIME type (JSON, PDF, etc.)
  • Response.AddHeader → custom headers
  • Response.Buffer → control buffering
  • Response.Flush → send partial content
  • Response.End → stop processing immediately
  • Response.Status → set HTTP status code

Always remember:

  • Use Server.HTMLEncode for user-controlled output
  • Use Response.Redirect after Session changes
  • Set .ContentType and .Charset for APIs
  • Response.End after redirects/downloads to avoid extra output

This is how millions of Classic ASP pages sent HTML, redirected users, set cookies, returned JSON, and forced downloads — and many legacy Indian systems still use exactly this Response object style in 2026.

Next class?

  • Want a full example combining Response + Session + Cookies + login?
  • Or how to stream large files without memory issues?
  • Or compare Classic ASP Response vs modern ASP.NET Core HttpResponse?
  • Or move to the next W3Schools topic (ASP Cookies or ASP Sessions)?

Just tell me — I’m here! 🚀🇮🇳 Keep learning strong, Webliance! 😊

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *