I make use of ajax call in my ASP.NET Core MVC
view pages
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 method"
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> MyLongRunningMethod(MyViewModel viewModel)
{
await MyProcess.Longprocess1();
await MyProcess.Longprocess2();
await MyProcess.Longprocess3();
await MyProcess.Longprocess4();
return PartialView("_MyPartialPage");
}
This works but only has an issue for a long running process. I get the following error during debug mode when the process takes longer than around 2 minutes
I understand this is to do with expiration timeout
in previous versions of ASP.NET MVC you can apparently increase the timeout in your asp.net controller action.
HttpContext.Current.Server.ScriptTimeout = 90000;
However this doesn't exist in ASP.NET Core
I want to increase the timeout for debugging and deployment for a particular asp.net controller.
For production I can set it globally in the web.config
by adding requestTimeout to the existing httpPlatform tag.
e.g. for 10 minutes
<httpPlatform requestTimeout="00:10:00" ....
A similar question was asked but the answer giving using an CancellationToken
but reading it, it doesn't seem it can help me with the timeouts.
- How do I set the timeouts in Visual Studio 2015 debug mode like I can do when I deploy it?
- IS there a per controller timeout setting like there was in
ASP.NET 4
?
question from:
https://stackoverflow.com/questions/37474309/timeouts-with-long-running-asp-net-mvc-core-controller-httppost-method 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…