31

I use the latest version of ASP.Net MVC 2 RC.

My question is, how do I redirect from one action that's in the "Blog"-area to the index-action in the home-controller that exists in the "root" of my application (no area)?

I tried:

return RedirectToAction("index", "home");

but this redirects to /Blog/home, where Blog is the name of my Area.

2 Answers 2

73

Try this:

return RedirectToAction("index", "home", new { area = "" });
1
  • Thank you, it worked. However, the ViewData seems to get lost :S I'll use Sessions instead :)
    – Mickel
    Jan 13, 2010 at 19:54
5

If using the default routing this should work too, not sure what happens to the ViewData.

return Redirect("~/");
1
  • 3
    This doesn't work for me, but I didn't downvote because it might do for someone else.
    – Rob Kent
    Oct 18, 2011 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.