Redirects in ASP.NET MVC 5

To redirect the user to another page (either external or internal), we can use Redirect method like below.

Remember that to redirect to external url, we need to provide complete url starting with http. For internal redirect, url can be provided from root of the application.

To redirect the user to another action method from the controller action method, we can use RedirectToAction method.

Above action method will simply redirect the user to AddNewPage action method.

Above method will redirect the user to Edit action method with id parameter value as 1, ie it will bring the record id 1 in edit mode.

So the url would look like

Without Area  : “/{ControllerName}/Edit/1“.

With Area         : “/{ControllerName}/Admin/Edit/1“.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)