The fact that TempData is stored in session and my session is in turn stored in external process demands that anything being stored must be "Serializable".
Objects like ViewDataDictionary or even ModelStateDictionary are NOT [Serializable]. For MVC PRG I just need to pass the modelstate errors and the invalid object.
I've already marked the object as [Serializable] (I'm using xml serializer to "stringify" my obj and then store it - because its a L2S Entity so need to avoid circular refs as well). Ref SO Post
TempDate["modelToPass"] = Serialization.Serialize<MyModel>(modelToPass);
And likewise I can translate my ModelState object (only for the errors) into a "simpler" object and transform it into something like
KeyValuePair<string,List<string>>[]
In short, I'm trying to make my modelstate and modelObject "serializable" so that I can put them in TempData and persist the PRG pattern.
There're some other approaches to deploy our own TempData and store TempData in cookies, etc.. but I don't want to complicate things. Do let me know if anyone has a better solution to this.
Some Ref urls