165

Is there a way to redirect to a specific action/controller on a different Area?

Jonathan
  • 32,202
  • 38
  • 137
  • 208

3 Answers3

315

Did you try this?:

return RedirectToAction("action", "controller", new { area = "area" });
eu-ge-ne
  • 28,023
  • 6
  • 71
  • 62
  • 5
    I am not seeing this work when I go from an area back to the main app. Area=""?? – MvcCmsJon Oct 29 '10 at 04:29
  • 35
    @MvcCMsJon `return RedirectToAction("action", "controller", new { area = "" });` should do it. – kim3er Dec 10 '10 at 16:45
  • `return RedirectToAction("Index", "Users", new { area = "Administration" });` is giving `No route matches the supplied values.` – swinn Nov 23 '22 at 18:08
57

Your answer was helpful to me. Just wanted to add below:

If you want to redirect from one area to another area, above code works well.

And, if you want to redirect from one area to a controller/view which is not there in the area folder (i.e. in most cases, your front end), you can specify area = "".

i.e.

return RedirectToAction("action", "controller", new { area = "" });
Suhani Mody
  • 691
  • 6
  • 10
3

Try this

return RedirectToAction("ActionName", "AreaName/ControllerName");
Abdulla Sirajudeen
  • 1,269
  • 1
  • 16
  • 29