RedirectToAction 被忽略

RedirectToAction gets ignored

我正在使用 ASP.NET 5. 使用浏览器 Chrome.

我的控制器有以下操作方法

public async Task<IActionResult> Index()
{
    return View();
}

[HttpPost]
public IActionResult DoSomething()
{
    //do something
    return RedirectToAction("Index");
}

当我运行

http://localhost:59693/MyArea/MyController/DoSomething

通过索引

中的POST

并在行上设置断点

 return RedirectToAction("Index");

它只是忽略该行并转到下一行而不调用 Index 操作方法。

并显示在浏览器中

http://localhost:59693/MyArea/MyController/DoSomething

空白屏幕。

当然,如果您有一个 return 语句,那么它会立即从该方法中 returns 而不会跳转到下一行。真奇怪。

我什至试过了

 return RedirectToAction("Index","MyController,new {area="MyArea"});

当我在我的 Index Action Method 上放置断点时,它永远不会被命中。

我什至试过了

 return Redirect("http://www.google.com");

它仍然显示

http://localhost:59693/MyArea/MyController/DoSomething

ASP.NET5 中的一些错误?

如果上述方法不起作用,如何从同一控制器中的操作方法调用操作方法?

我将 DoSomething 操作方法更改为异步并添加了 await 子句

[HttpPost]
public async Task<IActionResult> DoSomething()
{
    await _db.callsql();
    //do something start

    return RedirectToAction("Index");
}

这个问题似乎是因为 actionmethod Index 是异步的但 DoSomething 不是,再加上我单步执行代码。