Search code examples
asp.net-mvcaction-filter

ActionExecutingContext HttpContext.Session is null


I am using MVC Actionfilter (Global) to call db to get user data and i try to store that in session. Coding as mentioned in Dependency Injection in ASP.net Session_Start method. Everything works fine in local machine.

But in production machine, my filterContext.HttpContext.Session (filterContext being ActionExecutingContext) is always null.

I dont know what more information i can give, but if somebody asks questions I am ready to provide more answers.

Please let me know what i can check.


Solution

  • Adding the below to the web.config fixed the problem, although i dont know why it has to be done.

    <system.webServer>
      <modules>
        <remove name="Session" />
        <add name="Session" type="System.Web.SessionState.SessionStateModule"/>
      </modules>
    </system.webServer>