【问题标题】:Async Action Method with ActionController / AsyncActionController [duplicate]带有 ActionController / AsyncActionController 的异步操作方法 [重复]
【发布时间】:2016-10-05 00:46:43
【问题描述】:

我可以在继承 Controller 的控制器类中使用 Async 和 Await 关键字在 MVC 中编写一个 Action Method,那么为什么/AsyncController 基类的目的是什么?

在代码中以下两种方法有什么区别

    public class FileUploadController : Controller
    {
        public async Task<ActionResult> Index()
        {...}
    }

 public class FileUploadController : AsyncController
{
    public async Task<ActionResult> Index()
    {...}
}

【问题讨论】:

    标签: asp.net-mvc


    【解决方案1】:

    我们知道异步任务有助于优化池 http 请求,

    大多数 Web 开发人员都知道 ASP.NET 的请求处理管道。 HTTP 请求在从 ThreadPool 中获取的 Thread 上同步处理。处理此请求的线程被阻止执行任何其他操作,例如处理另一个传入请求

    Here 是关于它的有趣文章, 也许会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-03
      • 2018-08-13
      • 2017-05-30
      • 2016-04-07
      • 1970-01-01
      • 2020-04-22
      • 2018-02-15
      相关资源
      最近更新 更多