ASP.NET MVC AsyncController vs async await

Andrew Holer

Could somebody please explain what's the execution difference or performance benefit of using async await over AsyncController (Link here) for achieving asynchrony. I searched the Internet and Stackoverflow etc. and found that MVC 4 onwards we should use Tasks async await etc. and AsyncController is the thing of the past (and please feel free to correct me on this one if I've misunderstood).

Reni Calonge

Now Asynchronous controllers are as easy to do as standard controllers, and thanks to the Task library and to the async/await keywords async calls are easier to implement and less error prone than before. This raises another problem: do not overuse them. If doing async with short tasks and with lots of requests the server will spend more time in thread switching than executing your code. So never do it just for the sake of it, but use some grain of salt and do performance testing.

AsyncController was dropped in MVC 4 wherein it is still there for compatibility for MVC3. You can also write simpler codes in await async and better way than subclassing AsyncController

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related