3

There are some systems within a .NET project I'm working on which use StateServer. We're now using Appfabric cache for caching some stuff which we get from DB. Can these two co exist in the same config file?

The session state part of my Config file looks like this

<sessionState mode="StateServer" cookieless="true" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" regenerateExpiredSessionId="true" timeout="30" stateNetworkTimeout="30"/>
<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
  <providers>
    <!-- specify the named cache for session data -->
    <add name="AppFabricCacheSessionStoreProvider" type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider" cacheName="default" />
  </providers>
</sessionState>

Obviously, this throws an error that session state is already defined and that i cant re-define it.

Till we replace StateServer systems with Appfabric Caching systems ,which will take some time for us (its a very big project), we dont want to disturb the existing systems. Hence this question.

krishwader
  • 11,341
  • 1
  • 34
  • 51
  • Unclear why you have to use `AppFabricCacheSessionStoreProvider` if you are using AppFabric just for caching. Also unclear what results you expect from having 2 sessions state providers... And what is you concern about switching - unless you've heavily customized session state management replacing one out-of-process session state with another should have almost no impact on application. – Alexei Levenkov May 28 '13 at 05:01
  • on using AppFabricCacheSessionStoreProvider - This is just the start of a big system rebuild. We've been using HttpContext.Runtime.Caching till now and we're shifting to distributed caching system. We serve a lot of ppl so this seemed better. – krishwader May 28 '13 at 05:36
  • And yes we've customised session state management. I'm not spsd to disclose our custom soln so i used StateServer mode as an example :) sorry abt that :) A simple question. Is what im asking possible? Can two providers exist? – krishwader May 28 '13 at 05:40
  • I can't imagine how 2 session providers can co-exist (as single blob of sessions data needs to be stored and loaded from a place - how 2 will decide which one to store particular user's data). On caching - I don't believe AppFabricCacheSessionStoreProvider is requirement for using distributed caching portion of AppFabric. – Alexei Levenkov May 28 '13 at 06:29

1 Answers1

2

No, you can only have one unique active session state provider at the same time and it is also not possible to dynamically change at runtime.

In past, I also investigated this article in order to create a session store wrapper. Finally, I gave up because of complexity and poor performance.

Cybermaxs
  • 24,378
  • 8
  • 83
  • 112