System.Net is a large namespace that contains many members. It is far beyond the scope of this chapter to discuss them all, or to discuss all aspects related to Internet programming. (In fact, an entire book is needed to fully cover networking and C#’s support for it in detail.) However, it is worthwhile to list the members of System.Net so that you have an idea of what is available for your use.
The classes defined by System.Net are shown here:
AuthenticationManager | Authorization |
Cookie | CookieCollection |
CookieContainer | CookieException |
CredentialCache | Dns |
DnsPermission | DnsPermissionAttribute |
DownloadDataCompletedEventArgs (Added by C# 2.0.) | DownloadProgressChangedEventArgs (Added by C# 2.0.) |
DownloadStringCompletedEventArgs (Added by C# 2.0.) | EndPoint |
EndpointPermission | FileWebRequest |
FileWebResponse | FtpWebRequest (Added by C# 2.0.) |
FtpWebResponse (Added by C# 2.0.) | HttpListener (Added by C# 2.0.) |
HttpListenerBasicIdentity (Added by C# 2.0.) | HttpListenerContext (Added by C# 2.0.) |
HttpListenerException (Added by C# 2.0.) | HttpListenerPrefixCollection (Added by C# 2.0.) |
HttpListenerRequest (Added by C# 2.0.) | HttpListenerResponse (Added by C# 2.0.) |
HttpVersion | HttpWebRequest |
HttpWebResponse | IPAddress |
IPEndPoint | IPHostEntry |
IrDAEndPoint (Added by C# 2.0.) | NetworkCredential |
OpenReadCompletedEventArgs (Added by C# 2.0.) | OpenWriteCompletedEventArgs (Added by C# 2.0.) |
ProtocolViolationException | ServicePoint |
ServicePointManager | SocketAddress |
SocketPermission | SocketPermissionAttribute |
UploadDataCompletedEventArgs (Added by C# 2.0.) | UploadFileCompletedEventArgs (Added by C# 2.0.) |
UploadProgressChangedEventArgs (Added by C# 2.0.) | UploadStringCompletedEventArgs (Added by C# 2.0.) |
UploadValuesCompletedEventArgs (Added by C# 2.0.) | WebClient |
WebException | WebHeaderCollection |
WebPermission | WebPermissionAttribute |
WebProxy | WebRequest |
WebRequestMethods (Added by C# 2.0.) | WebResponse |
System.Net defines the following interfaces:
IAuthenticationModule | ICertificatePolicy | ICredentialPolicy (Added by C# 2.0.) |
ICredentials | ICredentialsByHost (Added by C# 2.0.) | IWebProxy |
IWebProxyScript (Added by C# 2.0.) | IWebRequestCreate |
It defines these enumerations:
AuthenticationSchemes (Added by C# 2.0.) | DecompressionMethods (Added by C# 2.0.) | FtpStatusCode (Added by C# 2.0.) |
HttpRequestHeader (Added by C# 2.0.) | HttpResponseHeader (Added by C# 2.0.) | HttpStatusCode |
NetworkAccess | SecurityProtocolType | TransportType |
WebExceptionStatus |
System.Net also defines several delegates.
Although System.Net defines many members, only a few are needed to accomplish most common Internet programming tasks. At the core of networking are the abstract classes WebRequest and WebResponse. These classes are inherited by classes that support a specific network protocol. (A protocol defines the rules used to send information over a network.) For example, the derived classes that support the standard HTTP protocol are HttpWebRequest and HttpWebResponse.
Even though WebRequest and WebResponse are easy to use, for some tasks, you can employ an even simpler approach based on WebClient. For example, if you only need to upload or download a file, then WebClient is often the best way to accomplish it.