I Have following code:
Controller:
public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Step1(FormCollection form) { TempData['messageStatus'] = new Random().Next(1, 1000); return RedirectToAction('Step1'); }
View:
<%=TempData['messageStatus']%>
in first time in view im getting 12345 for example, but when i request second time of course i must get something else instead 12345 for example 54321 but not, im getting same result 12345, how can u explain it? RedirectToAction cache pages?
where does it mean i must put Guid in my urls for resolving problems with cache? what do u think about this issue?
I’m guessing you’re running into caching problems. It’s not a problem with redirect to action. All RedirectToAction does is issues a redirect response to your browser telling it to request Step01. Then your browser makes a request for Step01.
In that case, your browser might have Step01 cached. So you need to add a Response header in STep01 indicating it should never be cached. You can do this like so:
Or you can add a random querystring to the redirect to action call by passing in an arbitrary value.