How to fix "Provider must implement the class 'System.Web.SessionState.SessionStateStoreProviderBase' error asp.net
Asked Answered
B

2

9

I am trying to implement Azure cache for redis to manage session's in my application. This is working on localhost. After hosting to IIS got compile error in webconfig file.

I have created azure cache for redis in azure portal. I have made respective changes in code. It's working when I run with source code on local host. After hosting to IIS got the following error

"Provider must implement the class
System.Web.SessionState.SessionStateStoreProviderBase

<sessionState mode="Custom" customProvider="MySessionStateStore">
      <providers>
        <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="myhostname" accessKey="Key1" ssl="true" />
      </providers>    
    </sessionState>

Module added as following

<system.webServer>
    <modules>
      <remove name="Session" />
      <add name="Session" type="Microsoft.AspNet.SessionState.SessionStateModuleAsync, Microsoft.AspNet.SessionState.SessionStateModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode" />
    </modules>
  </system.webServer>

I expected sessions values to store on azure cache for redis. But It's not working after hosting on IIS.

Belt answered 8/7, 2019 at 9:27 Comment(7)
are you transforming your web.config when deploying to IIS?Harv
@Harv - I'm having the same issue - have the config as above and am transforming the web.config via octopus deploy when deploying to an Azure App ServiceNatachanatal
@anD666 Be careful with transforming, especially the modules section is tricky. Look at the transformed endresult, and compare with the local version.Harv
@Harv - The transformation isn't touching the modules section. it's just adding the session state section.Natachanatal
@anD666 you need the modules section as well...Harv
@Harv - sorry, poor explanation in my previous comment. The module for the SessionStateModuleAsync is already in the web.config. When I pull down the files from the web server they are as expected. The extracted web directory even works locally so I'm at a lossNatachanatal
Any news on this? I'm facing the same issueUndertrump
D
9

You can try this under app.config/web.config

<modules>
<remove name="Session" />
<add name="Session" type="Microsoft.AspNet.SessionState.SessionStateModuleAsync,Microsoft.AspNet.SessionState.SessionStateModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode" />

if this doesn't work as well, if you have an option, use non-SSL port and see if that works.

Daile answered 26/10, 2020 at 17:32 Comment(0)
U
0

For anyone passing by that might have the same issue and for whom adding the Session tag didn't work, your application pool might be configured as 'Classic'

From this post, it seems Microsoft.AspNet.SessionState.SessionStateModuleAsync doesn't support classic application pools

You need to switch it to 'Integrated' like so :

enter image description here

Microsoft official application pools documentation

Undertrump answered 11/8, 2020 at 7:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.