Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

16. Networking > Client-Side Classes

Client-Side Classes

WebRequest and WebResponse are the common base classes for managing both HTTP and FTP client-side activity, as well as the “file:” protocol. They encapsulate the “request/response” model that these protocols all share: the client makes a request, and then awaits a response from a server.

WebClient is a convenient façade class that does the work of calling WebRequest and WebResponse, saving you some coding. WebClient gives you a choice of dealing in strings, byte arrays, files, or streams; WebRequest and WebResponse support just streams. Unfortunately, you cannot rely entirely on WebClient because it doesn’t support some features (such as cookies).

HttpClient is another class that builds on WebRequest and WebResponse (or more specifically, HttpWebRequest and HttpWebResponse) and is new to Framework 4.5. Whereas WebClient acts mostly as a thin layer over the request/response classes, HttpClient adds functionality to help you work with HTTP-based web APIs, REST-based services, and custom authentication schemes.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint