System.Net.WebRequest.GetResponse Method

When overridden in a descendant class, returns a response to an Internet request.

Syntax

public virtual WebResponse GetResponse ()

Returns

A System.Net.WebResponse containing the response to the Internet request.

Exceptions

TypeReason
NotSupportedExceptionThis method is not overridden in the derived class.
System.Net.WebException

The request timed out.

-or-

An error occurred while processing the request.

Remarks

The WebRequest.GetResponse method sends a request to an Internet resource and returns a System.Net.WebResponse instance. If the request has already been initiated by a call to WebRequest.GetRequestStream, the WebRequest.GetResponse method completes the request and returns any response.

The WebRequest.GetResponse method provides synchronous access to the System.Net.WebResponse. For asynchronous access, use the WebRequest.BeginGetResponse(AsyncCallback, object) and WebRequest.EndGetResponse(IAsyncResult) methods.

Note:

The System.Net.WebRequest class is an abstract class. The actual behavior of System.Net.WebRequest instances at run time is determined by the descendant class returned by the WebRequest.Create(Uri) method. For more information about default values and exceptions, see the documentation for the descendant classes, such as System.Net.HttpWebRequest and System.Net.FileWebRequest.

Note:

If a WebException is thrown, use the WebException.Response and WebException.Status properties of the exception to determine the response from the server.

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0