title: How to enable SessionStateTempDataProvider via Web.config?
body: <p>I've deployed an MVC application to a web server and noticed on one of my buttons that it throws a <code>SessionStateTempDataProvider class requires session state to be enabled.</code> error.</p>
  
  <p>The error explains a lot, that I need to enable <code>SessionStateModule</code> and add that tag to my Web.config <a href="https://stackoverflow.com/questions/1602297/asp-net-mvc-handling-404s-the-sessionstatetempdataprovider-requires-sessions">as explained here</a>.</p>
  
  <p>But when I edit Web.config and run again, the same error is thrown. I had to add the <code>&lt;module&gt;</code> attribute as my config file didn't contain one. So I'm not sure if my formatting is off. The module attribute was added inside of the   <code>&lt;system.webServer&gt;</code></p>
  
  <pre><code>&lt;modules&gt;
      &lt;add name="SessionStateModule" type="System.Web.SessionState.SessionStateModule" /&gt;
    &lt;/modules&gt;
  </code></pre>
  
  <p><strong>Question:</strong></p>
  
  <p>How can I enable Session State from the Web.config file? </p>
  
  <p><strong>Web.config file:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!--
    For more information on how to configure your ASP.NET application, please visit
    http://go.microsoft.com/fwlink/?LinkId=169433
    --&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt;
      &lt;section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data" /&gt;
      &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
    &lt;/configSections&gt;
    &lt;appSettings&gt;
      &lt;add key="webpages:Version" value="2.0.0.0" /&gt;
      &lt;add key="webpages:Enabled" value="false" /&gt;
      &lt;add key="PreserveLoginUrl" value="true" /&gt;
      &lt;add key="ClientValidationEnabled" value="true" /&gt;
      &lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&gt;
    &lt;/appSettings&gt;
    &lt;dataConfiguration defaultDatabase="NOTIFICATIONEntities" /&gt;
    &lt;connectionStrings&gt;
      //omitted connection string for privacy //
    &lt;/connectionStrings&gt;
    &lt;system.web&gt;
      &lt;compilation targetFramework="4.5" /&gt;
      &lt;httpRuntime targetFramework="4.5" /&gt;
      &lt;customErrors mode="Off"/&gt;
      &lt;authentication mode="Windows" /&gt;
      &lt;authorization&gt;
        &lt;deny users="?" /&gt;
      &lt;/authorization&gt;
      &lt;pages&gt;
        &lt;namespaces&gt;
          &lt;add namespace="System.Web.Helpers" /&gt;
          &lt;add namespace="System.Web.Mvc" /&gt;
          &lt;add namespace="System.Web.Mvc.Ajax" /&gt;
          &lt;add namespace="System.Web.Mvc.Html" /&gt;
          &lt;add namespace="System.Web.Optimization" /&gt;
          &lt;add namespace="System.Web.Routing" /&gt;
          &lt;add namespace="System.Web.WebPages" /&gt;
        &lt;/namespaces&gt;
      &lt;/pages&gt;
      &lt;trust level="Full" /&gt;
      &lt;identity impersonate="false" /&gt;
    &lt;/system.web&gt;
    &lt;system.webServer&gt;
      &lt;validation validateIntegratedModeConfiguration="false" /&gt;
    &lt;handlers&gt;&lt;remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" /&gt;&lt;remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" /&gt;&lt;remove name="ExtensionlessUrlHandler-Integrated-4.0" /&gt;&lt;add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /&gt;&lt;add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /&gt;&lt;add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /&gt;&lt;/handlers&gt;
    &lt;modules&gt;
      &lt;add name="SessionStateModule" type="System.Web.SessionState.SessionStateModule" /&gt;
    &lt;/modules&gt;
          &lt;security&gt;
              &lt;authentication&gt;
                  &lt;anonymousAuthentication enabled="false" /&gt;
              &lt;/authentication&gt;
          &lt;/security&gt;&lt;/system.webServer&gt;
    &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
    &lt;entityFramework&gt;
      &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"&gt;
        &lt;parameters&gt;
          &lt;parameter value="v12.0" /&gt;
        &lt;/parameters&gt;
      &lt;/defaultConnectionFactory&gt;
    &lt;/entityFramework&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Screen shot of error:</p>
  
  <p><a href="https://i.stack.imgur.com/0MtJP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0MtJP.png" alt="enter image description here"></a></p>