Search code examples
asp.netsession-statetempdata

ASP.NET Session State and TempData


I've inherited a site which uses TempData to pass various model state objects back to contoller methods. i.e. a failed login will have the error message stored in the TempData object and read back out of memory when the index method gets called.

This all works fine if Session State is inproc, however I have implemeted a Session State database following this https://msdn.microsoft.com/en-us/library/ms229862.aspx

The site now doesn't redirect to the index method like it used to and is instead throwing 500's. I've read up on this and it seems like TempData should work!

Any suggestions on how to dig into this to find the real issue or any pointers on getting this to work?


Solution

  • Check that the objects are serializable. I've encountered a similar issue where inproc works and other session solutions don't, and it was down to the objects not being fully serializable.