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.
The RedirectToAction() Method This method is used to redirect to specified action instead of rendering the HTML. In this case, the browser receives the redirect notification and make a new request for the specified action.
RedirectToAction(String) Redirects to the specified action using the action name. RedirectToAction(String, Object) Redirects to the specified action using the action name and route values.
Use RedirectToActionResult in ASP.NET Core MVC This action result can be used to redirect to the specified action and controller. If no controller is specified it redirects to the specified action within the current controller.
RedirectToRoute(String, RouteValueDictionary)Redirects to the specified route using the route name and route dictionary.
Try this:
return RedirectToAction("index", "home", new { area = "" });
If using the default routing this should work too, not sure what happens to the ViewData.
return Redirect("~/");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With