Returning Void in Async method from WEB API Controller

坚强是说给别人听的谎言 提交于 2019-12-05 04:05:28

The ASP.NET runtime waits for it. You may find this video useful.

Most examples for async assume a UI context. ASP.NET also provides a context, but it's a "request" context - one for each HTTP request. My async/await post gives an overview of this "context", and the async/await FAQ goes into much more detail.

With return type void you don't wait for an object to return.. You wait for an operation to finish. You wait for your Task to finish.

If you return void, you will be returning 204 "No Content" Response message immediately regardless of the completion status of your asynchronous operation. This is done by the help of VoidResultConverter.

Note: On RC, you will see that it returns 200 "OK" response but with the RTM, it will return 204 "No Content" response.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!