We are making changes to ensure less processing is done on the Web request, however there may still be a chance that these limits are hit. Does anyone know if there is a way to configure a custom error page to be shown instead of the generic error page shown below?
Since you could not overcome the limitation about request timeout (230 second) in Azure App Service, you need to either optimize your server-side processing or you need to catch the exception and customize the response. I tried to capture the exception by using Application_Error event and custom HTTP Modules, but failed in the end.
For a workaround, you could specify the timeout for your action and capture the exception in your application before the timeout exception thrown by Azure App Service, then you could add your custom error page. You could leverage AsyncTimeoutAttribute and define your action as follows:
[AsyncTimeout(duration:10000)] //The timeout value in milliseconds.
[HandleError(ExceptionType = typeof(TimeoutException),
View = "TimeoutError")]
public async Task<ActionResult> LongTask(CancellationToken cancellationToken)
{
await Task.Delay(TimeSpan.FromSeconds(20), cancellationToken);
return Content("Done");
}
Note: HandleErrorAttribute
requires customErrors
to be enabled in your Web.Config. If the TimeoutException
happens, then you would be redirected to the particular MVC view you defined.