
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
790
Chapter 14
CHAPTER 14
Web
14.0 Introduction
The World Wide Web has worked its way into every nook and cranny of what most
.NET developers encounter when building their solutions today. Web services are on
the rise, and ASP.NET is one of the main players in the web application space.
Because of the general needs to deal with HTML and TCP/IP name resolution and
because uniform resource indicators and uniform resource locators are being used
for more and more purposes, developers need tools to help them concentrate on
building the best web-interactive applications they can. This chapter is dedicated to
taking care of some of the grunge that comes along with programming when the
Web is involved. This is not an ASP.NET tutorial chapter but rather some function-
ality that developers can use in both ASP.NET and other C#-based applications. For
more on ASP.NET, see the ASP.NET Cookbook and Programming ASP.NET, Second
Edition (both from O’Reilly).
14.1 Converting an IP Address to a Hostname
Problem
You have an IP address that you need to resolve into a hostname.
Solution
Use the Dns.GetHostEntry method to get the hostname for an IP address. In the fol-
lowing code, an IP address is resolved, and the hostname is accessible from the
HostName property of the IPHostEntry:
using System;
using System.Net; ...