Reputation: 215
In My Asp.net MVC code, I sometimes write
return RedirectToAction("Manage", "User", new {Area = "Users", id = userId});
and sometimes
return RedirectToAction("Manage", new {id = userId});
Which is the best method to use if I am in the same User controller ?
Are there any pros and cons ? I personally like the 2nd one as the routing takes care of the current controller and current area.
Upvotes: 0
Views: 829
Reputation: 585
Neither one of them is better than the other if the action is on the same controller.
Overloaded methods exist to cover diverse needs. RedirectToAction("ActionName", "ControllerName") exists to allow you to navigate to another controller.
Upvotes: 1
Reputation: 609
In the same controller you should use the second one, simply because it's shorter. Behind the scenes both of them wil use RouteValuesHelpers.MergeRouteValues.
In case you like to explore this further: http://dotnetinside.com/en/type/System.Web.Mvc/Controller/5.2.0.0
Upvotes: 1