1

a quick overview of our set up :- MVC web application for front end, this sends REST requests to an MVC Web API.

This is all working great, however, we have now introduced AngularJS to allow us to use 2 way data binding with javascript.

This is a really good framework, and we have started to utilise the ajax $http requests.

so, within angular, we are using $http to call the MVC controller which calls the REST WEB API, data is returned, serialised as JSON within the controller and sent to the angularJS request for 2 way data binding.

This issue that we are having, is that we are now making multiple HTTP Requests in one go, however, each request seems to wait for the previous to have been completed and we are struggling to work out why? we where expecting all the requests to be independent of each other, so that there would be no lag or wait time...

If anyone can offer any advise, it would be greatly appreciated

ps - I hope that all made sense

angular code below:-

    $scope.LoadResults();
    $scope.GetHistory();
    $scope.GetUserDetails();

 $scope.GetHistory = function () {
  $http.post('/user/GetHistory/', $scope.data).success(function (data, status, headers, config) {
});
}

 $scope.GetUserDetails= function () {
 $http.post('/user/GetUserDetails/1234', $scope.data).success(function (data, status, headers, config) {
});
}


$scope.LoadResults = function () {
    $scope.data = {
        frequency: $scope.frequency,
        direction: $scope.direction,
        view: $scope.view
    };
    var userid = $('#id').val();
    var url = '/user/' + userid + '/GetUserResults/';

    $http.post(url, $scope.data).success(function (data, status, headers, config) {
        if (data.msg != '') {
                        $scope.resultssummarydata = data.aaData;

        }
        else {
            $scope.errors.push(data.error);
        }
    });
}
10
  • 1
    Is the web server under heavy load? If the thread pool is running out of threads you might see that things are starting to queue up and not run in parallel immediately. In that case, consider using async / await to allow I/O heavy actions to free the thread while doing the I/O. Related answer: stackoverflow.com/a/15190138/700926 Commented Apr 3, 2014 at 19:44
  • hi, everything is running locally at the moment, and async / await is being used. I've been googling most of the day. do we need to set the MVC controller as an async controller? Commented Apr 3, 2014 at 19:48
  • You seem to be concerned about the MVC controller being async, but that should have nothing to do with it if you are making ajax calls to it via angular (or any js library for that matter). The controller does not have to be async, and you don't have to use await on the server side. Show some angular code. Commented Apr 3, 2014 at 20:06
  • 2
    Just a guess, but what if you disable session state on IIS? One other thing on using the REST word..actually you have more of a RPC web api than RESTful one. Commented Apr 3, 2014 at 21:03
  • 1
    I think Patko may be on to something, since your angular code looks ok. Try changing (or adding) this to your web.config: <sessionState mode="Off" />. Just a note--disabling session will mean you can no longer use TempData. Commented Apr 3, 2014 at 22:52

1 Answer 1

3

Note that if Patko wants to add this as an answer, he should get credit, since he is the one who really figured it out (I just supplied the means to turn sessions off).

Try changing (or adding) this to your web.config to turn sessions off:

<sessionState mode="Off" />.

The session implementation in ASP.Net is very strange. If multiple http requests come in from the same browser/user session, it serialized them and handles them one at a time. In addition to this, the session implementation is very inefficient--the whole session gets loaded into memory for each request.

There has been pretty wide criticism of the ASP.Net Session implementation over the years--a little googling will allow you to read up on it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.