I was wondering if somebody explain the difference for the listed classes
WebRequest is an abstract class. The HttpWebRequest class allows you to programmatically make web requests to the HTTP server.
What is a Web Request? A web request is a communicative message that is transmitted between the client, or web browsers, to the servers. This request is essential in providing the user with the correct and preferred webpages that the server will then display on the user's interface.
HttpWebRequest does not implement IDisposable so it does not require disposing. just set the httprequest object to null once your done with it.
In a nutshell, WebRequest—in its HTTP-specific implementation, HttpWebRequest—represents the original way to consume HTTP requests in . NET Framework. WebClient provides a simple but limited wrapper around HttpWebRequest. And HttpClient is the new and improved way of doing HTTP requests and posts, having arrived with .
They do different things.
WebRequest
is the abstract base class for HttpWebRequest
- you can't use it directly. It is the base class of other *Request
classes (for FTP, File and other types of web requests). These classes are all used for getting resources (files) from the web.
There is also a WebClient
class - probably the simplest to use of all the BCL classes designed to retrieve a resource from the Internet.
HttpRequest
, on the other hand represents a request for a resource in an ASP.NET application - this is the server side of a Request
.
The main difference is that HttpWebRequest
is an HTTP client, and HttpRequest
is server side to be used in an ASP.NET web application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With