Differences HttpRequest and httpRequestBase

1

From the controller the controller class gets the property Request and from System.Web.HttpContext.Current.Request but I do not understand the utility:

public class HomeController : Controller
{
    public ActionResult Index(HttpRequestMessage request)
    {
        HttpRequestBase base = Request;
        HttpRequest req = System.Web.HttpContext.Current.Request;
        return View();
    }
}

They also include HttpContext and HttpContextBase

    
asked by gvivetapl 04.11.2016 в 20:34
source

1 answer

0

HttpRequest is present in classes Page and UserControl as a GET-only property. Similarly, most of its properties are also GET-only (see 1). This class is used by the ASP.NET pages to obtain information about the incoming http request, p. Read the customer's IP, cookies, query string, etc. It is important to know that it is part of the "Old" Assembly System.Web, which has been around since. NET 1.1

HttpRequestMessage , on the other hand, is new to .NET 4.5. It is part of System.Net . It can be used by clients and services to create, send and receive requests and responses through HTTP. Replaces HttpWebRequest, which is obsolete in .NET 4.5

In HttpRequestBase and HttpRequestWrapper, the best I can do is quote only the documents

  

The HttpRequestWrapper class is derived from the HttpRequestBase class and   It serves as a container for the HttpRequest class. This class exposes   the functionality of the HttpRequest class and exposes the type of   HttpRequestBase The HttpRequestBase class allows you to replace the   original implementation of the HttpRequest class in your application with   a custom implementation, such as when you perform tests   drive outside ASP.NET

    
answered by 07.11.2016 / 16:45
source