hi,
I just made one web API with core 9 with entity framework and all actions, i found that all the methods are made with a sync.
q1) so my question is where or how it can help me , because in my case i call my controllers action methods from java script in JavaScript i can can it in async or synchronous way, question came to my mind do i need async in the action methods of controller.
q2) and if i am not beneficial in above case then where i would be?
yours sincerely

Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Jun 23, 2025, 10:28 AM EDT
Use
asyncin Web API when performing I/O operations. it improves performance, scalability, and responsiveness under load.Q-1 Ans:
if your controller interacts with databases (like EF Core), external APIs, or file systems. Even though JavaScript can call your API asynchronously, using
asyncon the server frees up threads during I/O operations, allowing more requests to be handled efficiently.Q-2 Ans:
asyncprevents thread pool exhaustion and improves performance.Good Luck!
rajesh yadav121 reputationPosted Jun 24, 2025, 9:14 AM EDT
in my case i have called a method of controller from javacript and method returns one table. so kindly explain this senario how i am getting benefited by async method raher than sync method of the controller ?
rajesh yadav121 reputationPosted Jun 28, 2025, 12:29 AM EDT
[HttpGet] public async Task>> GetDsp() { return await _context.Dsp.ToListAsync(); }thank u , is there any central configuration for a solution or project?
or i have to use as i have pased in above code.
Howher Michael131 reputationPosted Aug 20, 2025, 9:24 AM EDT
If you’re calling your controller methods from JavaScript, it usually makes sense to have async actions. Even if your JS can handle async or sync, making the controller async can help avoid blocking threads on the server when multiple requests come in.