Name

SaveAs

Synopsis

Request.SaveAs(filename, includeHeaders)

Saves the current HTTP request to disk, using the filename argument as the path and filename under which to save the request.

Parameters

filename

A String argument containing the path and filename under which the request should be saved.

includeHeaders

A Boolean argument indicating whether to save the HTTP header information as part of the request. Note that unless this is a POST request (or other request type with a request body), no information is saved if this argument is set to False.

Example

The example writes the HTTP request headers to the browser (for comparison purposes) and then saves the current request both with and without header information:

Sub Page_Load(  )
   Message.Text = Request.Headers
  
   ' Save HTTP Request and Headers to a file
   Request.SaveAs((Request.PhysicalApplicationPath & _
      "HTTPRequest.txt"), True)
   ' Save HTTP Request to a file
   Request.SaveAs((Request.PhysicalApplicationPath & _
      "HTTPRequest_NoHeaders.txt"), False)
End Sub

Notes

This method can be very useful when debugging because it allows you to look at all the information sent in a given request (which is particularly useful in POST requests).

Get ASP.NET in a Nutshell 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.