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.
For instance:
[AcceotVerb("GET")]
public ActionResult Test()
{
TempData["Test"] = "Error";
}
[AcceotVerb("POST")]
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?
Thanks
/Todor
![]() |
0 |
![]() |
Hi
This works under RC1 of MVC. Please upgrade to the latest version.
Thanks,
Jacques
![]() |
0 |
![]() |
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.
![]() |
0 |
![]() |