Implementing an Asynchronous Controller Action Method
Explore how to implement asynchronous controller action methods in ASP.NET Core. Learn to transform synchronous endpoints into async ones using the async and await keywords along with asynchronous database calls. Understand the performance benefits and scalable design of async REST APIs through practical load testing and profiling.
We'll cover the following...
Steps to implement an asynchronous controller action method
Now, we are going to change the implementation of the unanswered questions endpoint so that it's asynchronous:
We are going to start by creating an asynchronous version of the data repository method that gets unanswered questions. So, let's create a new method in the data repository interface underneath
GetUnansweredQuestionsinIDataRepository.cs:
The key difference with an asynchronous method is that it returns a Task of the type that will eventually be returned. ...