Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTPContext And Controllercontext in MVC

I read about HTTPContext And ControllerContext in MVC (fundamentalbook), but i don't know what is exactly HTTPContext And ControllerContext.

Could some one please explain these methods?

like image 474
Shahrooz Jafari Avatar asked Sep 19 '12 09:09

Shahrooz Jafari


People also ask

What is ControllerContext MVC?

ControllerContext(HttpContextBase, RouteData, ControllerBase) Initializes a new instance of the ControllerContext class by using the specified HTTP context, URL route data, and controller.

What is HttpContext?

The HttpContext encapsulates all the HTTP-specific information about a single HTTP request. When an HTTP request arrives at the server, the server processes the request and builds an HttpContext object. This object represents the request which your application code can use to create the response.

What is mvc6?

MVC 6 is a part of ASP.NET 5 that has been designed for cloud-optimized applications. The runtime automatically picks the correct version of the library when our MVC application is deployed to the cloud. The Core CLR is also supposed to be tuned with a high resource-efficient optimization.

What is ControllerBase?

ControllerBase : A base class for an MVC controller without view support. Controller : A base class for an MVC controller with view support. Thus if we are not creating views i.e. creating Web API use ControllerBase else use Controller.


1 Answers

HttpContext will give information about an individual HTTP request. ControllerContext will give information about an HTTP request for a specified controller.

See links below for more info....

HttpContext:

http://msdn.microsoft.com/en-us/library/system.web.httpcontext.aspx

ControllerContext:

http://msdn.microsoft.com/en-us/library/system.web.mvc.controllercontext(v=vs.108).aspx

like image 192
Jonny C Avatar answered Oct 27 '22 03:10

Jonny C