I have 3 async WebAPI which I call via JQuery AJAX at the same time when my MVC page is loaded. One, sometimes two or all of them are reaching the controller method very fast and sometimes one or two of them are delayed about 3 and 10 seconds. The execution of the work each async method is always extremely fast (a few milliseconds). The only solutions I've found is to disable session state (which makes no sense to me because it is disabled by default in WebAPI, I've tried it though but with no success) and that I should use async methods to be able to run all 3 requests from the same session in parallel which is what I am already doing.
I've also tried if it is something with IIS Express which I am using but IIS had the same effect. Also tried various browser but same issue.
I am really lost here, someone has a solution or and idea on what could possibly block my requests? Keep in mind the requests are blocked randomly and sometimes it's fine but mostly not and the delays of the other two requests are always 3 and 10 seconds.
my client side code (all 3 calls look like this):
$.ajax({
type: "GET",
url: "/api/follow/getFollows/" + this.userId,
contentType: "application/json",
dataType: "json",
processData: false,
success: (data) => {
this.handleLoadedFollows($("#followsList"), data);
},
error: (data) => { alert("error"); }
});
my async webAPI method looks like this (all 3 methods look like this):
[HttpGet]
[Route("getFollows/{userId}", Name = "Follow.GetFollows")]
public async Task<IHttpActionResult> GetFollows(Guid userId)
{
var entries = await _followService.GetFollowsAsync(userId, null, 20);
// create viewmodel
var viewModel = await _followViewModelFactory.CreateUserViewModelAsync(entries.Results);
return Ok(viewModel);
}