Search code examples
asp.net-mvcangularjsasynchronousasp.net-web-apiangular-resource

Do asp.net mvc apicontroller requests require async handling in addition to angular $resource


If I'm using asp.net mvc ApiControllers as my backing services layer and an angular front-end using $resource, do I need to also use the asp.net mvc async pattern?

I understand $resource is asynchronous and that it doesn't block the UI, but would I also benefit from using asp.net mvc's async to keep the server from blocking requests when I have many clients doing i/o intensive tasks?

Thanks! Scott


Solution

  • Yes, you would benefit, but these are orthogonal concerns.

    JavaScript uses asynchronous I/O because it is single threaded by default (barring Web Workers).

    How the server manages incoming requests is of no real concern to the UI... unless of course you have a large number of concurrent users.

    Asynchronous calls on the server with ASP.Net simply means that when an I/O operation has been initiated, the thread can be released to do other work. When the Network call, or Disk read completes, the server can then resume processing of the original request. The result is that your web server will be able to pack more requests into the same period of time than it would if the calls were blocking.

    Again, this isn't tied to the browser, or Angular in any way.