Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you get the "real" HttpContext within an ASP.NET MVC application?

People also ask

What is HttpContext in ASP.NET MVC?

HttpContext is a type which has a static Current property that you're using to get the current context. There isn't a System. Web. Mvc.

How does ASP.NET MVC application work?

In an ASP.NET MVC application, a URL corresponds to a controller action instead of a page on disk. In a traditional ASP.NET or ASP application, browser requests are mapped to pages. In an ASP.NET MVC application, in contrast, browser requests are mapped to controller actions.


Try System.Web.HttpContext.Current. It should do the trick.

Gets HTTP-specific information about an individual HTTP request.

MSDN


this.HttpContext.ApplicationInstance.Context