Chapter 13. Effective Use of the .NET Networking Classes

In This Chapter:

  • Using the Dns Class

  • Using the WebClient Class

  • Using the WebRequest and WebResponse Classes

  • Using the WebProxy Class

  • NTLM Authentication

  • SSL Communication

  • Posting Data

  • System.Net Errors

At times, you will need to request data from other Web servers within your ASP.NET application. At first, this idea might seem strange. After all, we have been talking about using Web services to get data from other servers. Although Web services are extremely useful and represent the current recommended way for obtaining data from other servers, not all servers will offer Web services to your application.

For instance, a page on another server might present data or information of some sort, and you would like to retrieve this information for use in your application. If this is an older server that does not support Web services, you might need to employ some more pedestrian data-retrieval methods. Essentially, you would request the Web page in which the data resides, then you would process the Web page and extract the data. This technique is commonly known as data scraping, in which you retrieve a Web page and extract data that you would like to use in your application. One important note, though, is that you must have permission before you can legally scrape data from another Web site. Make sure, before you use data from someone else's Web site, that you have the necessary permissions.

The System.Net namespace provides a simple programming interface to many of the protocols found in today's networks. This namespace includes WebRequest, WebResponse, Dns, WebProxy, and many other types of classes with which you can easily write networking applications. This namespace enables you to develop applications that use Internet resources, and the classes encapsulate them in such a way that you don't have to worry about the specific details of doing the networking. Table 13.1 gives a brief description of these classes.

Table 13.1. The Commonly Used .NET Networking Classes




This class makes a request to a Uniform Resource Identifier.


This class provides a response from a Uniform Resource Identifier.


This class provides simple domain name resolution functionality.


This class contains HTTP proxy settings for the WebRequest class.

ASP. NET Solutions - 24 Case Studies. Best Practices for Developers
ASP. NET Solutions - 24 Case Studies. Best Practices for Developers
ISBN: 321159659
Year: 2003
Pages: 175 © 2008-2017.
If you may any questions please contact us: