我应该使用AsyncController在ASP.NET MVC 4? [英] Should I use AsyncController at ASP.NET MVC 4?

查看:372
本文介绍了我应该使用AsyncController在ASP.NET MVC 4?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本类有这样的描述:

 规定了与ASP.NET MVC 3向后兼容性。

和源仅仅是:

 公共抽象类AsyncController:控制器
{
}

我不能找到有关这个类在MSDN中去precation任何文件。我应该取代AsyncController的用途来控制?


解决方案

  

我应该使用AsyncController在ASP.NET MVC 4?


没有。


  

我应该取代AsyncController的用途来控制?


是的,异步操作在新的方式实现在asp.net-MVC 4,使用的任务类


  

在组合中的ASP.NET MVC 4控制器类.NET 4.5使
  你写的异步操作方法,返回类型的对象
  任务。在.NET Framework 4中引入异步
  编程的概念被称为任务和ASP.NET MVC 4支持
  任务。任务再由任务类型和相关类型psented $ P $
  System.Threading.Tasks命名空间。在.NET Framework 4.5基础上
  用的await和异步的关键字,使这个异步支持
  与任务对象的工作更复杂得多previous异步
  的方法。在等待关键字是表示语法速记
  那一块code,应异步等待其他片
  code。 async关键字重新presents一个暗示,你可以用它来标记
  作为方法基于任务的异步方法。 AWAIT的组合,
  异步和任务目标使得它更容易为你写
  异步code在.NET 4.5。异步方法的新模式
  被称为基于任务的异步模式(TAP)。本教程
  假定您已经使用一些熟悉的异步编程
  等待和异步的关键字和工作空间。


使用ASP异步方法更多的阅读。 NET MVC 4

This class has this description:

Provided for backward compatibility with ASP.NET MVC 3.

And the source is just:

public abstract class AsyncController : Controller
{
}

I can´t find any documentation about deprecation of this class at MSDN. Should I replace uses of AsyncController to Controller?

解决方案

Should I use AsyncController at ASP.NET MVC 4?

No.

Should I replace uses of AsyncController to Controller?

Yes, asynchronous actions are implemented in new way in asp.net-mvc 4, using Task Class

The ASP.NET MVC 4 Controller class in combination .NET 4.5 enables you to write asynchronous action methods that return an object of type Task. The .NET Framework 4 introduced an asynchronous programming concept referred to as a Task and ASP.NET MVC 4 supports Task. Tasks are represented by the Task type and related types in the System.Threading.Tasks namespace. The .NET Framework 4.5 builds on this asynchronous support with the await and async keywords that make working with Task objects much less complex than previous asynchronous approaches. The await keyword is syntactical shorthand for indicating that a piece of code should asynchronously wait on some other piece of code. The async keyword represents a hint that you can use to mark methods as task-based asynchronous methods. The combination of await, async, and the Task object makes it much easier for you to write asynchronous code in .NET 4.5. The new model for asynchronous methods is called the Task-based Asynchronous Pattern (TAP). This tutorial assumes you have some familiarity with asynchronous programing using await and async keywords and the Task namespace.

More reading at Using Asynchronous Methods in ASP.NET MVC 4

这篇关于我应该使用AsyncController在ASP.NET MVC 4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆