title: Can we store Session state and Cache on Redis Cache in same application?
body: <p>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.</p>
  
  <p>web.config settings below,</p>
  
  <blockquote>
    <p>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"</p>
  </blockquote>
  
  <p>Similarly now i have to move current caching implementation on redis cahce for which i have implemented in below code snippet(in vb.net),</p>
  
  <pre><code> 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
  </code></pre>
  
  <p>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.</p>
  
  <p>We created one test application on azure portal and using same for session state and caching storage.</p>
  
  <p>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?</p>