1
votes

I am implementing redis cahce in my ongoing application in which i have successfully implemented redis cache for session state and now sessions are storing on redis cache.

web.config settings below,

add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" port="6280" throwOnError="true" connectionString="webapplication1.redis.cache.windows.net:6380,password=some password,ssl=True,abortConnect=False" host="webapplication1.redis.cache.windows.net" accessKey="some key" ssl="true"

Similarly now i have to move current caching implementation on redis cahce for which i have implemented in below code snippet(in vb.net),

 Public Function GetApplicationCacheData() As DataSet
            Const rawKey As String = "AKey_"
            Dim dsData As DataSet
            Dim connection As ConnectionMultiplexer = ConnectionMultiplexer.Connect("webapplication1.redis.cache.windows.net:6280,password=some password,ssl=True,abortConnect=False")
            Dim redisObj As IDatabase = connection.GetDatabase()
            Dim valueObj As RedisValue = redisObj.StringGet(rawKey)

            If Not valueObj.HasValue Then
                dsData = class1.GetApplicationCacheData()
                redisObj.StringSet(rawKey,JsonConvert.SerializeObject(dsData), TimeSpan.FromMinutes(90))
            Else
                dsData  = JsonConvert.DeserializeObject(Of DataSet)(redisObj.StringGet(rawKey))
            End If

            Return dsData
        End Function

Now problem is this caching implementation working fine if i run it separately from session state but when i implement session state and caching together in redis cache then sessions become null and page redirects to login page with form authentication.

We created one test application on azure portal and using same for session state and caching storage.

So my question is, can we use one application for both implementation or we should create another application on portal to run cache functionality in redis cahce or My implementation has some inconsistency?

1

1 Answers

0
votes

Have you tried setting the "applicationName" parameter on the Session State configuration?