【发布时间】:2016-09-25 06:03:04
【问题描述】:
我在我的ASP.NET Core MVC 视图页面中使用 ajax 调用
MyView.cshtml
$.ajax({
processData: false,
contentType: false,
data: new FormData(this),
type: $(this).attr('method'),
url: $(this).attr('action'),
cache: false,
success: function (data) {
$('#mydiv).html(data);
$('#bootstrapModal).modal('show');
Controller Post 方法"
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> MyLongRunningMethod(MyViewModel viewModel)
{
await MyProcess.Longprocess1();
await MyProcess.Longprocess2();
await MyProcess.Longprocess3();
await MyProcess.Longprocess4();
return PartialView("_MyPartialPage");
}
这可行,但仅在长时间运行的过程中存在问题。当进程花费超过 2 分钟左右时,我在调试模式下收到以下错误
我知道这与过期超时有关
在以前版本的 ASP.NET MVC 中,您显然可以增加您的 asp.net 控制器操作的超时时间。
HttpContext.Current.Server.ScriptTimeout = 90000;
但是 ASP.NET Core 中不存在此功能
我想增加特定 asp.net 控制器的调试和部署超时时间。
对于生产,我可以通过将 requestTimeout 添加到现有的 httpPlatform 标记来在 web.config 中全局设置它。
例如10分钟
<httpPlatform requestTimeout="00:10:00" ....
有人问了一个类似的问题,但answer 使用CancellationToken 给出但阅读它,它似乎不能帮助我解决超时问题。
- 如何像部署 Visual Studio 2015 调试模式一样设置超时?
- 是否有像
ASP.NET 4中那样的每个控制器超时设置?
【问题讨论】:
-
VS 调试模式的变化如下所述。 stackoverflow.com/questions/49172284/…
标签: c# asp.net-core asp.net-core-mvc timeout