In my MVC4 application running on Azure, I store sessions in a neighboring cache. As described in this Microsoft-provided How-to .
I run two small instances and everything works fine. I can log in to the application and I stay logged in when I view the application. So the session seems to work in both cases.
However, when I update the session data something like this:
HttpContext.Current.Session["someVar"] = "new value";
This change only affects the instance processing this particular request. Now, when I browse the application, sometimes I get the initial value, and sometimes I get the updated value.
I did not make any changes to the web.config file, so it looks exactly the same as when adding the Nuget package:
<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider"> <providers> <add name="AppFabricCacheSessionStoreProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="default" useBlobMode="true" dataCacheClientName="default" /> </providers> </sessionState>
Do I need to handle the sessions in a different way when using the Azure cache, or is this something else I am missing here?
source share