On the project that we are working, we are using MVC Privew5.
We have problem with sharing TempData between methods decorated with GET and POST.
public ActionResult Test()
TempData["Test"] = "Error";
public ActionResult Test(FormCollection form)
string test = TempData["Test"];
In the second method decorated with POST TempData will be null ...
Is there any solution, workaround?
This works under RC1 of MVC. Please upgrade to the latest version.
Yes, please upgrade to RC1. In addition, this really isn't how TempData is intended to be used. TempData is mainly used for storing data during a PRG scenario - you POST a form and set TempData, then redirect to GET and consume TempData in the GET method. If you're trying to set TempData in a GET and consume it in a POST, consider using a hidden form field instead.