How to getthe HttpContext.Application other than Controller class Custom class

  • Last Post 05 May 2017
Surendiran Balasubramanian posted this 01 March 2017

Hi All,

I have the below Controller class

public class HomeController : Controller
      public ActionResult Index(CustomerModel model)
            return View();

and I have a Validate.cs class file like below 

public class Validate
      public static void Test()

                     //Just assume this senario
                     return true;

In the test method of the Validate class we are not able to access the HttpContext.Application but we are able to access the HttpContext.Application in the HomeController.

I understand the HomeController inherit from Controller class because of that HttpContext.Application has value. 

Is there anyway I can access the HttpContext.Application in a class which doesnot inherit Contoller class. Please help

rajesh posted this 05 May 2017

Did you use HttpContext.Current.Application