我使用的是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
通过索引中的帖子
在这条线上有一个断点
return RedirectToAction("Index");它只是忽略这一行,然后转到下一行,而不调用Index action方法。
并在浏览器中显示。
http://localhost:59693/MyArea/MyController/DoSomething
有一个空白的屏幕。
当然,如果您有一个return语句,那么它将立即从该方法返回,不会跳转到下一行。真的很奇怪。
我甚至尽了全力
return RedirectToAction("Index","MyController,new {area="MyArea"});当我在Index方法上放置一个断点时,它永远不会被击中。
我甚至试过
return Redirect("http://www.google.com");它仍然显示
http://localhost:59693/MyArea/MyController/DoSomething
ASP.NET 5中的一些bug?
如果上面的操作方法不起作用,如何从同一控制器中的动作方法调用操作方法?
发布于 2015-12-14 07:35:22
我将我的DoSomething操作方法改为异步的,并添加了一个等待子句
[HttpPost]
public async Task<IActionResult> DoSomething()
{
await _db.callsql();
//do something start
return RedirectToAction("Index");
}问题似乎是因为actionmethod Index是异步的,但DoSomething不是异步的,再加上我跨出了代码。
https://stackoverflow.com/questions/34261205
复制相似问题