Issue when using Redis for storing session data Q&A

I am trying to store session in Redis by

  1. Setup of redis according to Education/Developer Education/Tasks/Redis at main · LitiumAB/Education · GitHub

  2. Adding the redis session connectionstring in web.config:

    <add name="RedisSessionStateConnectionString" connectionString="127.0.0.1:6379, name=SessionState:" />
    
  3. Configuring session in web.config

    <sessionState mode="Custom" customProvider="Redis">
       <providers>
         <add name="Redis" type="Microsoft.Web.Redis.RedisSessionStateProvider" connectionString="RedisSessionStateConnectionString" />
       </providers>
     </sessionState>
    

But this gives the error:

Parser Error Message: Could not load type 'Microsoft.Web.Redis.RedisSessionStateProvider'.

Line 123:    <sessionState mode="Custom" > customProvider="Redis">
Line 124:      <providers>
Line 125:        <add name="Redis" type="Microsoft.Web.Redis.RedisSessionStateProvider" connectionString="RedisSessionStateConnectionString" />
Line 126:      </providers>
Line 127:    </sessionState>

Litium version: 7.4.3 (prerelease)

  1. Install the nuget package RedisSessionStateProvider (read more):
    install-package Microsoft.Web.RedisSessionStateProvider

  2. Adjust Session-tag in web.config (this is adjusted automatically when installing the nuget package)

    From:
    <add name="Session" preCondition="" type="System.Web.SessionState.SessionStateModule" />`
    To: 
    <add name="Session" type="Microsoft.AspNet.SessionState.SessionStateModuleAsync, Microsoft.AspNet.SessionState.SessionStateModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode" />
    
2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.