Using the WebRequest and WebResponse Classes

A combination of WebRequest and WebResponse classes can be used to request data from Internet resources, and then to read the response. To do this, the first thing you must do is create a WebRequest object, as the following code shows you:

WebRequest wReq = WebRequest.Create( “http://www.SomeDomain.com/” ); 

The .NET framework provides protocol-specific WebRequest and WebResponse objects for resources that being with HTTP, HTTPS, and FILE. To access other protocols, you must implement protocol-specific descendants of WebRequest and WebResponse. This chapter deals only with HTTP and HTTPS data.

The next thing you should do is to set any properties required to perform the data retrieval request to ...

Get Special Edition Using® Microsoft® ASP.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.