I have an ASP.NET MVC project which uses TempData to carry an object from one controller action to another - which is in fact the same action but a version that accepts HTTP posts.
On my development machine this works as expected. On the test machine the TempData value is null in the second controller action.
Forum posts which I've seen suggest checking that sessionState is working - which I have done. Both websites have sessionState set to InProc - neither web.config contains a sessionState entry but I've checked that Session.Mode is InProc. If I put an object in Session in the first controller action I can retrieve it in the second on both machines.
I can work around this by re-doing the process u开发者_开发技巧sed to set TempData in the first controller action in the second but why might TempData be being lost on the test machine?
Make sure you aren't reading it from say - a layout (master page) an extra time. To be sure, wrap the call where you set/get this values and write trace information out to make sure you are only calling it when you expect. I had a similar issue on an app a while back (mvc2) and it turned out I was reading it when it first seemed I wasn't.
精彩评论