Chapter 41
Accessing the Internet
Chapters 37 through 39 discuss how you can use C# to write powerful, efficient, and dynamic Web pages using ASP.NET. For the most part, the clients accessing ASP.NET pages will be users running Internet Explorer or other Web browsers such as Opera or Firefox. However, you might want to add Web-browsing features to your own application, or you might need your applications to programmatically obtain information from a Web site. In this latter case, it is usually better for the site to implement a Web service. However, when you are accessing public Internet sites, you might not have any control over how the site is implemented.
This chapter covers facilities provided through the .NET base classes for using various network protocols, particularly HTTP and TCP, to access networks and the Internet as a client. In particular, this chapter covers:
- Downloading files from the World Wide Web
- Using the Web Browser control in a Windows Forms application
- Manipulating IP addresses and performing DNS lookups
- Socket programming with TCP, UDP, and socket classes
This chapter covers some of the lower-level means of getting at these protocols through the .NET Framework. You will also find other means of communicating via these items using technologies, such as the Windows Communication Foundation (WCF), which is covered in the next chapter.
The two namespaces of most interest for networking are System.Net and System.Net.Sockets. The System.Net namespace is generally ...