asp.net .net 4.7 web API
I am accessing a ASP.NET web API via jQuery. JQuery collects a number of ids and sends one ajax request per id.
If there is 1 id the query is processed in 6-10ms If there is more than 1 it can take 500-1000 ms as seen in browser web dev timing or in IIS log access log files. A stopwatch in controller is consistent for all queries below 10ms.
Same issue on both IIS prod server and local Dev machine.
function dashboardLoader() {
var tcs = $(".dashboardtc");
for (var i = 0; i < tcs.length; i++) {
var fid = $(tcs[i]).attr("data-fid");
$.ajax({
url: '/ctl/dashboardfeature/' + fid,
type: 'GET',
cache: false,
contentType: "application/json",
success: function (d1) {
adjustDashBoardCell(d1);
},
error: function (result) {
console.log(result.Message);
}
});
}
}
API:
[Authorize]
[Route("ctl/dashboardfeature/{fid}")]
[HttpGet]
public async Task<dashboardFeaturePayload> GetDashboardFeature(string fid)
{
try
{
var timer = new Stopwatch();
timer.Start();
if (!User.Identity.IsAuthenticated) return null;
string un = User.Identity.Name;
int fID = fid.val();
string rtn = await Task.FromResult<string>(DashboardCode.GetDashboardFeatureAPI(fID, true));
timer.Stop();
TimeSpan timeTaken = timer.Elapsed;
System.Diagnostics.Debug.WriteLine(timer.Elapsed.TotalMilliseconds.ToString());
return new dashboardFeaturePayload(fID, rtn);
}
catch (Exception ex)
{
AdminTask.ExceptionLoging(ex);
return new dashboardFeaturePayload(fid.val(), "ERROR");
}
}
Would appear to be link to the ability of IIS to process multiple requests arriving in the same time.
Web Dev Timing:
VS Output stopwatch: