ASP.NET MVC does browser refresh make TempData useless?

Myster picture Myster · Apr 15, 2010 · Viewed 15.9k times · Source

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?

Answer

cemsazara picture cemsazara · Oct 30, 2011

You should write

TempData.Keep("nameofthedata");

in your controller, then it will keep that data in refresh situations too.