System.Net.Requests 4.0.10.0 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.WebResponse System.Runtime.Serialization.ISerializable [System.Runtime.CompilerServices.Nullable(0)] [<System.Runtime.CompilerServices.Nullable(0)>] Provides an HTTP-specific implementation of the class. class. The class is used to build HTTP stand-alone client applications that send HTTP requests and receive HTTP responses. > [!NOTE] > Do not confuse with the class that is used in ASP.NET applications and whose methods and properties are exposed through ASP.NET's intrinsic `Response` object. You should never directly create an instance of the class. Instead, use the instance returned by a call to . You must call either the or the method to close the response and release the connection for reuse. It is not necessary to call both and , but doing so does not cause an error. Common header information returned from the Internet resource is exposed as properties of the class. See the following table for a complete list. Other headers can be read from the property as name/value pairs. The following table shows the common HTTP headers that are available through properties of the class. |Header|Property| |------------|--------------| |Content-Encoding|| |Content-Length|| |Content-Type|| |Last-Modified|| |Server|| The contents of the response from the Internet resource are returned as a by calling the method. ## Examples The following example returns an from an . :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebResponse/Overview/source.vb" id="Snippet1"::: ]]> System 4.0.0.0 Initializes a new instance of the class. Constructor System 4.0.0.0 System.Net.Requests 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 netstandard 2.1.0.0 [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] [<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>] [System.Obsolete("This API supports the .NET infrastructure and is not intended to be used directly from your code.", true)] [<System.Obsolete("This API supports the .NET infrastructure and is not intended to be used directly from your code.", true)>] Initializes a new instance of the class. To be added. Constructor System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.Requests 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] [<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>] [System.Obsolete("Serialization has been deprecated for HttpWebResponse.")] [<System.Obsolete("Serialization has been deprecated for HttpWebResponse.")>] [System.Obsolete("Serialization is obsoleted for this type. https://go.microsoft.com/fwlink/?linkid=14202")] [<System.Obsolete("Serialization is obsoleted for this type. https://go.microsoft.com/fwlink/?linkid=14202")>] [System.Obsolete("Serialization is obsoleted for this type. http://go.microsoft.com/fwlink/?linkid=14202")] [<System.Obsolete("Serialization is obsoleted for this type. http://go.microsoft.com/fwlink/?linkid=14202")>] A that contains the information required to serialize the new . A that contains the source of the serialized stream that is associated with the new . Initializes a new instance of the class from the specified and instances. interface for the class. ]]> Property System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.Requests 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 [System.Runtime.CompilerServices.Nullable(2)] [<System.Runtime.CompilerServices.Nullable(2)>] System.String Gets the character set of the response. A string that contains the character set of the response. property contains a value that describes the character set of the response. This character set information is taken from the header returned with the response. ## Examples The following example obtains the character set of the response. :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/CharacterSet/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebResponse/CharacterSet/source.vb" id="Snippet1"::: ]]> The current instance has been disposed. Method System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.Requests 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System.Void Closes the response stream. method closes the response stream and releases the connection to the resource for reuse by other requests. You should not access any properties of the object after the call to the `Close` method. If you do, an is thrown. You must call either the or the method to close the stream and release the connection for reuse. It is not necessary to call both and , but doing so does not cause an error. Failure to close the stream can cause your application to run out of connections. > [!NOTE] > This member outputs trace information when you enable network tracing in your application. ## Examples The following example demonstrates how to close a . :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/Close/httpwebresponse_close.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebResponse/Close/httpwebresponse_close.vb" id="Snippet1"::: ]]> This object has been disposed. Property System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.Requests 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System.String Gets the method that is used to encode the body of the response. A string that describes the method that is used to encode the body of the response. property contains the value of the Content-Encoding header returned with the response. ## Examples The following example uses the property to obtain the value of the Content-Encoding header returned with the response. :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/CharacterSet/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebResponse/CharacterSet/source.vb" id="Snippet1"::: ]]> The current instance has been disposed. Property System.Net.Requests 4.0.10.0 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Int64 Gets the length of the content returned by the request. The number of bytes returned by the request. Content length does not include header information. property contains the value of the Content-Length header returned with the response. If the Content-Length header is not set in the response, is set to the value -1. ## Examples The following example displays the value of this property. :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Credentials/httpwebrequest1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebRequest/Credentials/httpwebrequest1.vb" id="Snippet1"::: ]]> The current instance has been disposed. Property System.Net.Requests 4.0.10.0 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.String Gets the content type of the response. A string that contains the content type of the response. property contains the value of the Content-Type header returned with the response. ## Examples The following example displays the value of this property. :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Credentials/httpwebrequest1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebRequest/Credentials/httpwebrequest1.vb" id="Snippet1"::: ]]> The current instance has been disposed. Property System.Net.Requests 4.0.10.0 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.CookieCollection Gets or sets the cookies that are associated with this response. A that contains the cookies that are associated with this response. property provides an instance of the class that holds the cookies associated with this response. If the property of the associated is `null`, the property will also be `null`. Any cookie information sent by the server will be available in the property, however. ## Examples The following example sends a request to a URL and displays the cookies returned in the response. :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/Cookie/Overview/cookiessnippets.vb" id="Snippet1"::: ]]> The current instance has been disposed. Method System.Net.Requests 4.0.10.0 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System 1.0.5000.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Void to release both managed and unmanaged resources; to releases only unmanaged resources. Releases the unmanaged resources used by the , and optionally disposes of the managed resources. method, if it has been overridden. `Dispose()` invokes this method with the `disposing` parameter set to `true`. `Finalize` invokes this method with `disposing` set to `false`. When the `disposing` parameter is `true`, this method releases all resources held by any managed objects that this references. This method invokes the `Dispose()` method of each referenced object. > [!NOTE] > This member outputs trace information when you enable network tracing in your application. ]]> can be called multiple times by other objects. When overriding , be careful not to reference objects that have been previously disposed of in an earlier call to . For more information about how to implement , see Implementing a Dispose Method. For more information about and , see Cleaning Up Unmanaged Resources. Method System 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.Requests 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 [System.Obsolete("Serialization has been deprecated for HttpWebResponse.")] [<System.Obsolete("Serialization has been deprecated for HttpWebResponse.")>] [System.Obsolete("Serialization is obsoleted for this type. https://go.microsoft.com/fwlink/?linkid=14202")] [<System.Obsolete("Serialization is obsoleted for this type. https://go.microsoft.com/fwlink/?linkid=14202")>] [System.Obsolete("Serialization is obsoleted for this type. http://go.microsoft.com/fwlink/?linkid=14202")] [<System.Obsolete("Serialization is obsoleted for this type. http://go.microsoft.com/fwlink/?linkid=14202")>] System.Void The to populate with data. A that specifies the destination for this serialization. Populates a with the data needed to serialize the target object. are automatically tracked and serialized by the formatter. ]]> Method System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.Requests 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System.String The header value to return. Gets the contents of a header that was returned with the response. The contents of the specified header. to retrieve the contents of particular headers. You must specify which header you want to return. ## Examples This example creates a Web request and queries for a response. If the site requires authentication, this example will respond with a challenge string. This string is extracted using . :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/GetResponseHeader/httpwebresponse_getresponseheader.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebResponse/GetResponseHeader/httpwebresponse_getresponseheader.vb" id="Snippet1"::: ]]> The current instance has been disposed. Method System.Net.Requests 4.0.10.0 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.IO.Stream Gets the stream that is used to read the body of the response from the server. A containing the body of the response. method returns the data stream from the requested Internet resource. > [!NOTE] > You must call one of the , , , or methods to close the stream and release the connection for reuse. It's not necessary to close or dispose both and instances, but doing so doesn't cause an error. Failure to close or dispose the stream will cause your application to run out of connections. > [!NOTE] > This member outputs trace information when you enable network tracing in your application. ## Examples The following example demonstrates how to use to return the instance used to read the response from the server. :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/GetResponseStream/httpwebresponse_getresponsestream.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebResponse/GetResponseStream/httpwebresponse_getresponsestream.vb" id="Snippet1"::: ]]> There is no response stream. The current instance has been disposed. Property System.Net.Requests 4.0.10.0 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.WebHeaderCollection Gets the headers that are associated with this response from the server. A that contains the header information returned with the response. property is a collection of name/value pairs that contain the HTTP header values returned with the response. Common header information returned from the Internet resource is exposed as properties of the class. The following table lists common headers that the API exposes as properties. |Header|Property| |------------|--------------| |Content-Encoding|| |Content-Length|| |Content-Type|| |Last-Modified|| |Server|| ## Examples The following example writes the contents of all of the response headers to the console. :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/Headers/httpwebresponse_headers.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebResponse/Headers/httpwebresponse_headers.vb" id="Snippet1"::: ]]> The current instance has been disposed. Property System 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.Requests 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System.Boolean Gets a value that indicates whether both client and server were authenticated. if mutual authentication occurred; otherwise, . property. ]]> The current instance has been disposed. Property System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.Requests 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System.DateTime Gets the last date and time that the contents of the response were modified. A that contains the date and time that the contents of the response were modified. property contains the value of the Last-Modified header received with the response. The date and time are assumed to be local time. ## Examples This example creates an and queries for a response. This example then checks whether the entity requested had been modified any time today. :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/LastModified/httpwebresponse_lastmodified.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebResponse/LastModified/httpwebresponse_lastmodified.vb" id="Snippet1"::: ]]> The current instance has been disposed. Property System.Net.Requests 4.0.10.0 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.String Gets the method that is used to return the response. A string that contains the HTTP method that is used to return the response. returns the method that is used to return the response. Common HTTP methods are GET, HEAD, POST, PUT, and DELETE. ## Examples The following example checks the string contained in , to determine the Http method invoked by the Web server. :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/Method/httpwebresponse_method_server.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebResponse/Method/httpwebresponse_method_server.vb" id="Snippet1"::: ]]> The current instance has been disposed. Property System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.Requests 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System.Version Gets the version of the HTTP protocol that is used in the response. A that contains the HTTP protocol version of the response. property contains the HTTP protocol version number of the response sent by the Internet resource. ## Examples This example creates an and queries for an . The example then checks to see if the server is responding with the same version. :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/ProtocolVersion/httpwebresponse_protocolversion.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebResponse/ProtocolVersion/httpwebresponse_protocolversion.vb" id="Snippet1"::: ]]> The current instance has been disposed. Property System.Net.Requests 4.0.10.0 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Uri Gets the URI of the Internet resource that responded to the request. The URI of the Internet resource that responded to the request. property contains the URI of the Internet resource that actually responded to the request. This URI might not be the same as the originally requested URI, if the original server redirected the request. The property will use the Content-Location header if present. Applications that need to access the last redirected should use the property rather than , since the use of property may open security vulnerabilities. ## Examples This example creates a and queries for an and then checks to see whether the original URI was redirected by the server. :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/ResponseUri/httpwebresponse_responseuri.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebResponse/ResponseUri/httpwebresponse_responseuri.vb" id="Snippet1"::: ]]> The current instance has been disposed. Property System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.Requests 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System.String Gets the name of the server that sent the response. A string that contains the name of the server that sent the response. property contains the value of the Server header returned with the response. ## Examples The following example uses the property to display the Web server's name to the console. :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/Method/httpwebresponse_method_server.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebResponse/Method/httpwebresponse_method_server.vb" id="Snippet2"::: ]]> The current instance has been disposed. Property System.Net.Requests 4.0.10.0 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.HttpStatusCode Gets the status of the response. One of the values. parameter is a number that indicates the status of the HTTP response. The expected values for status are defined in the class. ## Examples The following example uses to verify that the status of the is OK. :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/StatusCode/httpwebresponse_statuscode_statusdescription.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebResponse/StatusCode/httpwebresponse_statuscode_statusdescription.vb" id="Snippet1"::: ]]> The current instance has been disposed. Property System.Net.Requests 4.0.10.0 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.String Gets the status description returned with the response. A string that describes the status of the response. to verify that the status of the is OK. :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/StatusCode/httpwebresponse_statuscode_statusdescription.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/System.Net/HttpWebResponse/StatusCode/httpwebresponse_statuscode_statusdescription.vb" id="Snippet2"::: ]]> The current instance has been disposed. Property System.Net.Requests 4.0.10.0 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 System 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Boolean Gets a value that indicates whether headers are supported. if headers are supported; otherwise, . Always returns . Method M:System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext) System 1.0.5000.0 2.0.0.0 2.0.5.0 4.0.0.0 netstandard 2.0.0.0 2.1.0.0 System.Net.Requests 4.1.0.0 4.1.1.0 4.1.2.0 5.0.0.0 6.0.0.0 7.0.0.0 8.0.0.0 9.0.0.0 10.0.0.0 11.0.0.0 [System.Obsolete("Serialization has been deprecated for HttpWebResponse.")] [<System.Obsolete("Serialization has been deprecated for HttpWebResponse.")>] [System.Obsolete("Serialization is obsoleted for this type. https://go.microsoft.com/fwlink/?linkid=14202")] [<System.Obsolete("Serialization is obsoleted for this type. https://go.microsoft.com/fwlink/?linkid=14202")>] [System.Obsolete("Serialization is obsoleted for this type. http://go.microsoft.com/fwlink/?linkid=14202")] [<System.Obsolete("Serialization is obsoleted for this type. http://go.microsoft.com/fwlink/?linkid=14202")>] System.Void The object into which this will be serialized. The destination of the serialization. Serializes this instance into the specified object. To be added.