Comments/Troubleshooting

As you will see, the many methods of the Response object give you powerful control over what you can send to the client in the headers and body of the HTTP response. However, one of the most valuable uses for the Response object is in debugging your scripts. Although Microsoft's Internet Information Server 4.0 does allow for server-side debugging, these debugging tools—at least currently—are sometimes not quite as functional as you need them to be when working on some piece of have-to-finish code. The Response object allows you to view the current state of your server-side scripts on the fly, as follows.

Assume you want to view the current value for your server-side variable, strMyValue, at a certain place in your script. You can insert the following code and view the value anywhere in your script:

Response.Clear
Response.Write "The value of strMyValue is " & strMyValue
Response.End

Although simple, this code actually does three very important things. First, it clears the buffer (assuming your Buffer property is set to True) that the output of your server scripting has been filling to be sent to the browser. Next, it inserts only a single line of text displaying your variable's value. Finally—and this is very important—it completely ends processing of your server script and sends the contents of the Response object's buffer to the user. No code after Response.End is processed! This can be invaluable for those pieces of code that work up until a certain point ...

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.