When running an ajax request I get an error message:
Failed to load resource: the server responded with a status of 500 (OK)
The problem is that the server error does not seem to occur. When I run the application on my local machine but with the azure database I don't get the error message. Only the published azure application generates this error. I have done remote debugging and even though the browser display this error the server keeps handling the request and some minutes later it finishes the request. As if there actually was not server error.
The server needs about 10 minutes to finish the request. I believe it has something to do with the fact that the request it very long (because it works on smaller databases). I know azure has restrictions on CPU time on app service level free but I switched up to basic (no cpu time restrictions) so that should not be a problem. The request is very sql intense (about 20k sql queries).
Ajax call:
$.ajax({
async: true,
cache: false,
type: "POST",
url: FooURL,
contentType: 'application/json',
dataType: "json",
data: JSON.stringify(null),
success: function (error_message) {
$("#FooBar").removeClass("loading");
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
Controller:
[Authorize]
[RequireHttpsAttribute]
public class FooController : Controller
{
private FooBarModel foobarModel = new FooBarModel();
public ActionResult UpdateFooBarModel()
{
foobarModel.UpdateModel();
return Json("Success");
}
There is apparently an idle timeout in azure which is described here. The default value is set to 4 min and can be configured up to 30 min if you run your application on a VM. I solved it by creating a table in the database with stores the current status of request.
Table:
);
Instead of calling the method directly I create a task and returns the id of the update status row.
Ajax call:
}