Dump the response.

  • Thread starter Robert Strickland
  • Start date
R

Robert Strickland

Is there a quick way to see response stream? I need to dump the stream into
a file. Request has the InputStream but Response does not have the same
(OutputStream is write only). Do I have to use a filter?
 
K

Ken Cox [Microsoft MVP]

Hey Robert,

Here's a quick and not-too-dirty way to get the response to a file. You'll
need to make sure the ASPNET account has write permissions to the location:

Dim uriString As String = _
"http://msdn.microsoft.com/"
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)
' Create an instance of StreamWriter to write text to a file.
Dim sw As System.IO.StreamWriter = New
System.IO.StreamWriter("c:\TestFile.txt")
' Add some text to the file.
sw.Write(System.Text.Encoding.ASCII.GetString(responseArray))
sw.Close()

If you need to see more information and don't need it programmatically, try
this add-on to IE:

http://www.blunck.info/iehttpheaders.html

Does this help?

Ken
Microsoft MVP [ASP.NET]
Toronto
 
W

William F. Robertson, Jr.

You can use the Filter property of the HttpResponse object. This is a
Stream derived object that you can use to manipulate the outgoing response.
That also means you can take the outgoing response and place it into a file.

http://aspalliance.com/71

HTH,

bill
 
R

Robert Strickland

Thanks...

William F. Robertson said:
You can use the Filter property of the HttpResponse object. This is a
Stream derived object that you can use to manipulate the outgoing
response.
That also means you can take the outgoing response and place it into a
file.

http://aspalliance.com/71

HTH,

bill
 
R

Robert Strickland

Thanks

Ken Cox said:
Hey Robert,

Here's a quick and not-too-dirty way to get the response to a file. You'll
need to make sure the ASPNET account has write permissions to the
location:

Dim uriString As String = _
"http://msdn.microsoft.com/"
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)
' Create an instance of StreamWriter to write text to a file.
Dim sw As System.IO.StreamWriter = New
System.IO.StreamWriter("c:\TestFile.txt")
' Add some text to the file.
sw.Write(System.Text.Encoding.ASCII.GetString(responseArray))
sw.Close()

If you need to see more information and don't need it programmatically,
try this add-on to IE:

http://www.blunck.info/iehttpheaders.html

Does this help?

Ken
Microsoft MVP [ASP.NET]
Toronto


Robert Strickland said:
Is there a quick way to see response stream? I need to dump the stream
into a file. Request has the InputStream but Response does not have the
same (OutputStream is write only). Do I have to use a filter?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top