Returns a response from an Internet resource.
Assembly: System (in System.dll)
The stream is already in use by a previous call to BeginGetResponse.
The ContentLength is greater than zero, but the application does not write all of the promised data.
The request cache validator indicated that the response for this request can be served from the cache; however, this request includes data to be sent to the server. Requests that send data must not use the cache. This exception can occur if you are using a custom cache validator that is incorrectly implemented.
Abort was previously called.
The time-out period for the request expired.
An error occurred while processing the request.
The method returns a WebResponse object that contains the response from the Internet resource. The actual instance returned is an HttpWebResponse, and can be typecast to that class to access HTTP-specific properties.
A ProtocolViolationException is thrown in several cases when the properties set on the HttpWebRequest class are conflicting. This exception occurs if an application sets the ContentLength property and the SendChunked property to true, and then sends an HTTP GET request. This exception occurs if an application tries to send chunked to a server that only supports HTTP 1.0 protocol, where this is not supported. This exception occurs if an application tries to send data without setting the ContentLength property or the SendChunked is false when buffering is disabled and on a keepalive connection (the KeepAlive property is true).
You must call the Close method to close the stream and release the connection. Failure to do so may cause your application to run out of connections.
When using the POST method, you must get the request stream, write the data to be posted, and close the stream. This method blocks waiting for content to post; if there is no time-out set and you do not provide content, the calling thread blocks indefinitely.
Multiple calls to return the same response object; the request is not reissued.
Your application cannot mix synchronous and asynchronous methods for a particular request. If you call the GetRequestStream method, you must use the method to retrieve the response.
This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in the .NET Framework.