How to get an 'MvcApplication' instance in ASP.NET controller?
asp.net-mvc
Solution
Try this:
var app = HttpContext.Current.ApplicationInstance as MvcApplication;
Problem
I think `MvcApplication` is a global singleton. I want to get the instance of `MvcApplication` in the controller. Then I put the following code in controller: ``` MvcApplication app = HttpContext.Current.Application as MvcApplication; ``` It gives me an error: Error 2 'System.Web.HttpContextBase' does not contain a definition for 'Current' and no extension method 'Current' accepting a first argument of type 'System.Web.HttpContextBase' could be found (are you missing a using directive or an assembly reference?) Why? How do I access `MvcApplication` in the controller?