Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect from one Area's action to a action in the "root"-area?

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.

like image 272
Mickel Avatar asked Jan 13 '10 18:01

Mickel


People also ask

How do I redirect to another action?

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.

What is redirect to 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.

What is used to redirect from one action to another in MVC core?

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.

What is redirect to route in MVC?

RedirectToRoute(String, RouteValueDictionary)Redirects to the specified route using the route name and route dictionary.


2 Answers

Try this:

return RedirectToAction("index", "home", new { area = "" }); 
like image 140
Dan Atkinson Avatar answered Oct 06 '22 02:10

Dan Atkinson


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

return Redirect("~/"); 
like image 36
Jeep Avatar answered Oct 06 '22 01:10

Jeep