MVC redirecttoaction with parameter with Area

I don't have enough reputation to add a comment, or to make a change so I will just add this as an answer. The marked answer does not adequately explain the answer and will confuse some people. It assumes a default home controller since it has not explicitly stated the controller and will not work for all situations when another controller is defined for the area. There are many overloads for the Redirect but the simplest one to achieve the stated goal is of the form:

return RedirectToAction("Action", "Controller", new { id=YourId, Area="AreaName" });

Other answers on this post has rewritten the original code correctly but also did not draw the attention to you needing to specify the controller in most situations.

The anonymous object acts as a bag for the MVC route mapper to map all the route values that you may want to include in your Redirects.


return RedirectToAction("Index", new { id = currentcoupon.Companyid.id, Area="Admin" });

If you need to redirect from an controller registered in an area to an controller without area, you have to set the area value to empty like this:

return RedirectToAction("Welcome", "Home", new { Area="" });

Without Area="" you will not be able to redirect to a different controller.