TempData doesn't work with GET and POST decorated methods

 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
Ahilius
2/23/2009 7:04:55 PM
asp.net.mvc 4300 articles. 0 followers. Follow

2 Replies
764 Views

Similar Articles

[PageSpeed] 55

Hi

This works under RC1 of MVC. Please upgrade to the latest version.

Thanks,

 Jacques

0
jeloff
2/23/2009 7:28:49 PM

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
levib
2/23/2009 8:16:15 PM
Reply: