RedisSessionStateProvider does not work

472 views
Skip to first unread message

Jignesh Patel

unread,
May 24, 2016, 1:20:02 AM5/24/16
to Redis DB
Hi,

On my Azure Cloud Service web role, I want to use Redis Cache for session management. For that I have added following to my web.config

<sessionState timeout="2000" mode="Custom" customProvider="MySessionStateStore"><providers>
<add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" connectionString="jlmscloud.redis.cache.windows.net:6380,password=XXXXXXXXXXXXXXXX,ssl=True,abortConnect=False" />
      </providers></sessionState>


On my Login.aspx page, I have one my own object 'AuditLog' which stores log to Azure Table. 

While I browse Login page with debug break point, all lines of code works well. But after last line of code it gives me following error,

"Type 'AuditLog'  is not marked as serializable."

Audit log object is not being stored to session state. Even though it gave me such error. While searching, I found that object being stored to session should be serilazable, but in my case I am not storing auditlog object to session even i am getting this error.

To avoid this error I have added [Serializable] above class definition. 

After doing that I have started getting below error. 

Type 'Microsoft.WindowsAzure.Storage.Table.CloudTable' in Assembly 'Microsoft.WindowsAzure.Storage, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.

In my auditlog class I am storing log text to Azure table. 

While searching on internet I found that azure storage object is serializable after version 2.4. But I am using 7.0 version of Azure storage library which is latest. 

I am surprised to see such error, as this code has nothing to do with session. 


Jignesh


Jon Cole

unread,
May 25, 2016, 3:40:41 PM5/25/16
to Redis DB
My first guess would be that something that you are trying to write to the session state has a direct or indirect reference to the AuditLog object.  For instance, if object X holds a reference to object Y, which holds a reference to an instance of the AuditLog class, then serializing X would serialize Y, which would try to serialize the AuditLog instance that it holds onto...

Jon

Jignesh Patel

unread,
May 30, 2016, 8:17:43 AM5/30/16
to Redis DB
Thanks Jon,

You were write. It was the issue. 

But, after fixing that i am stuck up in other issue. I have created new topic https://groups.google.com/forum/#!topic/redis-db/nTzzquTQJ7k for the same. Please check if you can help me on that as well.

Jignesh
Reply all
Reply to author
Forward
0 new messages