[英]How to redirect to action in ASP.NET Core WebAPI?
I've got two actions in my ASP.NET Core Web API application's controller: 我的ASP.NET Core Web API应用程序的控制器中有两个动作:
[HttpGet("get-all")]
public IActionResult GetAll() { ... }
and 和
[HttpDelete("{id}")]
public IActionResult Delete(int id)
{
...
return RedirectToAction("GetAll");
}
Delete
action always redirects to itself and never to GetAll
. Delete
操作始终重定向到自身,永远不会重定向到GetAll
。 Why so? 为什么这样? In the same time similar redirect from
Post
action works ok. 同时,
Post
动作的类似重定向也能正常工作。
Can't find any docs on the subject. 找不到关于这个主题的任何文档。 Any help?
有帮助吗?
Have you tried to use RedirectToActionResult? 您是否尝试过使用RedirectToActionResult? Like this (change ControllerName with your actual Controller's name ):
像这样(用你的实际控制器名称更改ControllerName):
RedirectToActionResult("GetAll", "ControllerName", null);
Hope you'll find this useful. 希望你会发现这很有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.