If I redirect to a new page passing TempData to initialise the page it works fine, however if the user presses the refresh button in their browser the TempData is no-longer available.
Given this, is there any situation where TempData could be used reliably?
Or any way to remove or mitigate the problem of users refreshing?
If I redirect to a new page passing TempData to initialise the page it
Share
In MVC 1, yes, temp data is lost after the next request after you store a key.
With MVC 2 however, the temp data is lost after the first attempt to access it.
You can always use Session, which TempData uses anyway, to solve the temp data loss issue your having.
From the MVC 2 Beta Release Notes:
You can also look directly in the MVC 2 source to see these changes:
MVC 1:
MVC 2: