RedirectToAction not refreshing the page

asp.net, asp.net-mvc

Solution

I'm guessing you're running into caching problems.

Decorate your ActionInControllerB and ActionInControllerA methods with:

[OutputCache(Location=System.Web.UI.OutputCacheLocation.None)]

Problem

I have a scenario where I am on a view page and calling a action method in controller A that calls another action in controller B via a RedirectToAction return, and this action returns the view that Im already on. I want the page to refresh to reflect the updates to the system state these two actions have made, but MVC seems to decide the page does not need to be refreshed as I'm returning to the same view. How do I force a refresh? Example: ``` //user is on A/index, and submits a form that calls this in contoller B public ActionResult ActionInControllerB() { //do stuff return RedirectToAction(ActionNames. ActionInControllerA, ControllerNames.A); } public ActionResult ActionInControllerA() { //do stuff return View("index"); } ```

Original source