ControllerBase.RedirectToAction 方法

定义

重载

RedirectToAction()

将 (Status302Found) 重定向到与当前操作同名的操作。 “controller”和“action”名称是从当前请求的环境值检索的。

RedirectToAction(String)

使用 actionName将 (Status302Found) 重定向到指定的操作。

RedirectToAction(String, Object)

使用 actionNamerouteValues将 (Status302Found) 重定向到指定的操作。

RedirectToAction(String, String)

使用 actionNamecontrollerName将 (Status302Found) 重定向到指定的操作。

RedirectToAction(String, String, Object)

Status302Found 使用指定的 、 controllerNamerouteValues将 () 重定向到指定的actionName操作。

RedirectToAction(String, String, String)

Status302Found 使用指定的 、 controllerNamefragment将 () 重定向到指定的actionName操作。

RedirectToAction(String, String, Object, String)

Status302Found 使用指定的 、、 controllerNamerouteValuesfragment将) (重定向到指定的actionName操作。

RedirectToAction()

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

将 (Status302Found) 重定向到与当前操作同名的操作。 “controller”和“action”名称是从当前请求的环境值检索的。

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

返回

为响应创建的 RedirectToActionResult

属性

示例

对名为“Product”的操作的 POST 请求将更新产品并重定向到操作(也称为“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();
}

适用于

RedirectToAction(String)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

使用 actionName将 (Status302Found) 重定向到指定的操作。

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

参数

actionName
String

操作的名称。

返回

为响应创建的 RedirectToActionResult

属性

适用于

RedirectToAction(String, Object)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

使用 actionNamerouteValues将 (Status302Found) 重定向到指定的操作。

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

参数

actionName
String

操作的名称。

routeValues
Object

路由的参数。

返回

为响应创建的 RedirectToActionResult

属性

适用于

RedirectToAction(String, String)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

使用 actionNamecontrollerName将 (Status302Found) 重定向到指定的操作。

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

参数

actionName
String

操作的名称。

controllerName
String

控制器的名称。

返回

为响应创建的 RedirectToActionResult

属性

适用于

RedirectToAction(String, String, Object)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Status302Found 使用指定的 、 controllerNamerouteValues将 () 重定向到指定的actionName操作。

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

参数

actionName
String

操作的名称。

controllerName
String

控制器的名称。

routeValues
Object

路由的参数。

返回

为响应创建的 RedirectToActionResult

属性

适用于

RedirectToAction(String, String, String)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Status302Found 使用指定的 、 controllerNamefragment将 () 重定向到指定的actionName操作。

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

参数

actionName
String

操作的名称。

controllerName
String

控制器的名称。

fragment
String

要添加到 URL 的片段。

返回

为响应创建的 RedirectToActionResult

属性

适用于

RedirectToAction(String, String, Object, String)

Source:
ControllerBase.cs
Source:
ControllerBase.cs
Source:
ControllerBase.cs

Status302Found 使用指定的 、、 controllerNamerouteValuesfragment将) (重定向到指定的actionName操作。

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

参数

actionName
String

操作的名称。

controllerName
String

控制器的名称。

routeValues
Object

路由的参数。

fragment
String

要添加到 URL 的片段。

返回

为响应创建的 RedirectToActionResult

属性

适用于