Come on, now. This was documentation on the WebException.Response property
of the WebException class. The code in it was an example of how to use the
WebException.Response property. It had legitimate code for getting a
Response from an HttpWebRequest, but using an invalid URL, in order to get
the WebException. The introductory text before the example read:
Remarks
Some Internet protocols, such as HTTP, return otherwise valid responses
indicating that an error has occurred at the protocol level. When the
response to an Internet request indicates an error, WebRequest.GetResponse
sets the Status property to WebExceptionStatus.ProtocolError and provides
the WebResponse containing the error message in the Response property of the
WebException that was thrown. The application can examine the WebResponse to
determine the actual error.
Example
[Visual Basic, C#, C++] The following example checks the Status property and
prints to the console the StatusCode and StatusDescription of the underlying
HttpWebResponse instance.
You were supposed to read the code, read the documentation, derive the
correct code for getting a Response from an HttpWebRequest, note the
location in the .Net Framework class library documentation for future use,
and adapt the code to your needs.
For future use, the documentation for the entire CLR class library is in
that reference, and it should be very useful to you when this sort of
situation arises.
The full documentation for the HttpWebRequest class can be found at:
http://msdn.microsoft.com/library/de...classtopic.asp
The full documentation for the HttpWebResponse class can be found at:
http://msdn.microsoft.com/library/de...classtopic.asp
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Who is Mighty Abbott?
A twin turret scalawag.
"Kevin Spencer" <> wrote in message
news:...
> Here you go:
>
> http://msdn.microsoft.com/library/de...ponsetopic.asp
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> Who is Mighty Abbott?
> A twin turret scalawag.
>
> <> wrote in message
> news: ups.com...
>> Can someone give me an example of how I can execute a program on a
>> corporate server and then download the response to the user? I'm not
>> sure if I'm asking this right.
>> Here is the asp code used today. I am attempting to recreate in
>> ASP.NET.
>>
>> Thanks in advance,
>> Clem
>> --------------------------------------------------------------------------------------------------------------------------------------
>> Set HttpObj = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1")
>> HttpObj.setTimeouts 5000, 5000, 15000, 15000
>> HttpObj.open "GET", "http://" & serverpath & "/doc_qanda.exe?" &
>> Escape(doc_num) & ",1", False
>> HttpObj.send
>> html = HttpObj.responseText
>> pos = Instr(html, "window.location=""") + 17
>>
>> If Not Response.IsClientConnected Then
>> Set HttpObj = Nothing
>> Response.End
>> End If
>>
>> If pos > 17 Then
>> HttpObj.setTimeouts 5000, 5000, 15000, 15000
>> HttpObj.open "GET", Mid(html, pos, Instr(pos, html, """") - pos),
>> False
>> HttpObj.send
>> End If
>>
>> BinaryData = HttpObj.responseBody
>> ContentType = HttpObj.getResponseHeader("Content-Type")
>> Set HttpObj = Nothing
>> If Not Response.IsClientConnected Then
>> Response.End
>> End If
>>
>> Response.AddHeader "Content-Type", ContentType
>> Response.AddHeader "Content-Length", LenB(BinaryData)
>> Response.AddHeader "Content-Disposition", "attachment; filename=" &
>> Escape(handle)
>> Response.BinaryWrite BinaryData
>> Response.Flush
>> %>
>> --------------------------------------------------------------------------------------------------------------------------------------
>>
>
>