RedirectToAction between areas?
Asked Answered
W

3

167

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

Wormhole answered 8/9, 2009 at 3:54 Comment(0)
D
318

Did you try this?:

return RedirectToAction("action", "controller", new { area = "area" });
Diane answered 8/9, 2009 at 5:41 Comment(3)
I am not seeing this work when I go from an area back to the main app. Area=""??Glendon
@MvcCMsJon return RedirectToAction("action", "controller", new { area = "" }); should do it.Distinctive
return RedirectToAction("Index", "Users", new { area = "Administration" }); is giving No route matches the supplied values.Laryngitis
S
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 = "" });
Sidesaddle answered 6/8, 2012 at 9:8 Comment(0)
U
3

Try this

return RedirectToAction("ActionName", "AreaName/ControllerName");
Underline answered 3/3, 2021 at 5:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.