Application state in context RRS feed

  • Question

  • User81789783 posted
    i am using ApplicationState variable inside recurring job,it thows an exception ,ApplicationState is null,can anybody help?
    () => Fun1()(),

    public Fun1()

    //some processin here
    //Response =some intialisation

    HttpContext.Current.Application["DateAndTime"] = Response;

    Friday, May 17, 2019 9:55 AM

All replies

  • User61956409 posted

    Hi erum,

    HttpContext.Current.Application["DateAndTime"] = Response;

    The code snippet that you shared is assignment statement, do you mean that code snippet causes the error "ApplicationState is null"? or the issue is caused by another code snippet?

    Please clarify more about your problem, so that we can understand it better.

    With Regards,

    Fei Han

    Monday, May 20, 2019 2:05 AM
  • User753101303 posted


    HttpContext.Current returns the current http request so more likely it won't work if you run this code from a background job. ASP.NET is not meant to schedule jobs so It ry to stay away from that (for example you could call an http page from some other scheduling mechanism).

    Monday, May 27, 2019 9:38 AM