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.

Dan Atkinson
  • 11,391
  • 14
  • 81
  • 114
Mickel
  • 6,658
  • 5
  • 42
  • 59

2 Answers2

73

Try this:

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

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

return Redirect("~/");
Jeep
  • 165
  • 2
  • 8