ControllerBase.RedirectToAction Method

Definition

Overloads

RedirectToAction()

Redirects (Status302Found) to an action with the same name as current one. The 'controller' and 'action' names are retrieved from the ambient values of the current request.

RedirectToAction(String)

Redirects (Status302Found) to the specified action using the actionName.

RedirectToAction(String, Object)

Redirects (Status302Found) to the specified action using the actionName and routeValues.

RedirectToAction(String, String)

Redirects (Status302Found) to the specified action using the actionName and the controllerName.

RedirectToAction(String, String, Object)

Redirects (Status302Found) to the specified action using the specified actionName, controllerName, and routeValues.

RedirectToAction(String, String, String)

Redirects (Status302Found) to the specified action using the specified actionName, controllerName, and fragment.

RedirectToAction(String, String, Object, String)

Redirects (Status302Found) to the specified action using the specified actionName, controllerName, routeValues, and fragment.

RedirectToAction()

Redirects (Status302Found) to an action with the same name as current one. The 'controller' and 'action' names are retrieved from the ambient values of the current request.

public:
 virtual Microsoft::AspNetCore::Mvc::RedirectToActionResult ^ RedirectToAction();
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToAction ();
[<Microsoft.AspNetCore.Mvc.NonAction>]
abstract member RedirectToAction : unit -> Microsoft.AspNetCore.Mvc.RedirectToActionResult
override this.RedirectToAction : unit -> Microsoft.AspNetCore.Mvc.RedirectToActionResult
Public Overridable Function RedirectToAction () As RedirectToActionResult

Returns

The created RedirectToActionResult for the response.

Attributes

Examples

A POST request to an action named "Product" updates a product and redirects to an action, also named "Product", showing details of the updated product.

[HttpGet]
public IActionResult Product(int id)
{
    var product = RetrieveProduct(id);
    return View(product);
}

[HttpPost]
public IActionResult Product(int id, Product product)
{
    UpdateProduct(product);
    return RedirectToAction();
}

Applies to

RedirectToAction(String)

Redirects (Status302Found) to the specified action using the actionName.

public:
 virtual Microsoft::AspNetCore::Mvc::RedirectToActionResult ^ RedirectToAction(System::String ^ actionName);
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToAction (string actionName);
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToAction (string? actionName);
[<Microsoft.AspNetCore.Mvc.NonAction>]
abstract member RedirectToAction : string -> Microsoft.AspNetCore.Mvc.RedirectToActionResult
override this.RedirectToAction : string -> Microsoft.AspNetCore.Mvc.RedirectToActionResult
Public Overridable Function RedirectToAction (actionName As String) As RedirectToActionResult

Parameters

actionName
String

The name of the action.

Returns

The created RedirectToActionResult for the response.

Attributes

Applies to

RedirectToAction(String, Object)

Redirects (Status302Found) to the specified action using the actionName and routeValues.

public:
 virtual Microsoft::AspNetCore::Mvc::RedirectToActionResult ^ RedirectToAction(System::String ^ actionName, System::Object ^ routeValues);
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToAction (string actionName, object routeValues);
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToAction (string? actionName, object? routeValues);
[<Microsoft.AspNetCore.Mvc.NonAction>]
abstract member RedirectToAction : string * obj -> Microsoft.AspNetCore.Mvc.RedirectToActionResult
override this.RedirectToAction : string * obj -> Microsoft.AspNetCore.Mvc.RedirectToActionResult
Public Overridable Function RedirectToAction (actionName As String, routeValues As Object) As RedirectToActionResult

Parameters

actionName
String

The name of the action.

routeValues
Object

The parameters for a route.

Returns

The created RedirectToActionResult for the response.

Attributes

Applies to

RedirectToAction(String, String)

Redirects (Status302Found) to the specified action using the actionName and the controllerName.

public:
 virtual Microsoft::AspNetCore::Mvc::RedirectToActionResult ^ RedirectToAction(System::String ^ actionName, System::String ^ controllerName);
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToAction (string actionName, string controllerName);
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToAction (string? actionName, string? controllerName);
[<Microsoft.AspNetCore.Mvc.NonAction>]
abstract member RedirectToAction : string * string -> Microsoft.AspNetCore.Mvc.RedirectToActionResult
override this.RedirectToAction : string * string -> Microsoft.AspNetCore.Mvc.RedirectToActionResult
Public Overridable Function RedirectToAction (actionName As String, controllerName As String) As RedirectToActionResult

Parameters

actionName
String

The name of the action.

controllerName
String

The name of the controller.

Returns

The created RedirectToActionResult for the response.

Attributes

Applies to

RedirectToAction(String, String, Object)

Redirects (Status302Found) to the specified action using the specified actionName, controllerName, and routeValues.

public:
 virtual Microsoft::AspNetCore::Mvc::RedirectToActionResult ^ RedirectToAction(System::String ^ actionName, System::String ^ controllerName, System::Object ^ routeValues);
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToAction (string actionName, string controllerName, object routeValues);
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToAction (string? actionName, string? controllerName, object? routeValues);
[<Microsoft.AspNetCore.Mvc.NonAction>]
abstract member RedirectToAction : string * string * obj -> Microsoft.AspNetCore.Mvc.RedirectToActionResult
override this.RedirectToAction : string * string * obj -> Microsoft.AspNetCore.Mvc.RedirectToActionResult
Public Overridable Function RedirectToAction (actionName As String, controllerName As String, routeValues As Object) As RedirectToActionResult

Parameters

actionName
String

The name of the action.

controllerName
String

The name of the controller.

routeValues
Object

The parameters for a route.

Returns

The created RedirectToActionResult for the response.

Attributes

Applies to

RedirectToAction(String, String, String)

Redirects (Status302Found) to the specified action using the specified actionName, controllerName, and fragment.

public:
 virtual Microsoft::AspNetCore::Mvc::RedirectToActionResult ^ RedirectToAction(System::String ^ actionName, System::String ^ controllerName, System::String ^ fragment);
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToAction (string actionName, string controllerName, string fragment);
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToAction (string? actionName, string? controllerName, string? fragment);
[<Microsoft.AspNetCore.Mvc.NonAction>]
abstract member RedirectToAction : string * string * string -> Microsoft.AspNetCore.Mvc.RedirectToActionResult
override this.RedirectToAction : string * string * string -> Microsoft.AspNetCore.Mvc.RedirectToActionResult
Public Overridable Function RedirectToAction (actionName As String, controllerName As String, fragment As String) As RedirectToActionResult

Parameters

actionName
String

The name of the action.

controllerName
String

The name of the controller.

fragment
String

The fragment to add to the URL.

Returns

The created RedirectToActionResult for the response.

Attributes

Applies to

RedirectToAction(String, String, Object, String)

Redirects (Status302Found) to the specified action using the specified actionName, controllerName, routeValues, and fragment.

public:
 virtual Microsoft::AspNetCore::Mvc::RedirectToActionResult ^ RedirectToAction(System::String ^ actionName, System::String ^ controllerName, System::Object ^ routeValues, System::String ^ fragment);
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToAction (string actionName, string controllerName, object routeValues, string fragment);
[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToAction (string? actionName, string? controllerName, object? routeValues, string? fragment);
[<Microsoft.AspNetCore.Mvc.NonAction>]
abstract member RedirectToAction : string * string * obj * string -> Microsoft.AspNetCore.Mvc.RedirectToActionResult
override this.RedirectToAction : string * string * obj * string -> Microsoft.AspNetCore.Mvc.RedirectToActionResult
Public Overridable Function RedirectToAction (actionName As String, controllerName As String, routeValues As Object, fragment As String) As RedirectToActionResult

Parameters

actionName
String

The name of the action.

controllerName
String

The name of the controller.

routeValues
Object

The parameters for a route.

fragment
String

The fragment to add to the URL.

Returns

The created RedirectToActionResult for the response.

Attributes

Applies to