gpt4 book ai didi

asp.net-mvc - 我应该在 ASP.NET MVC 4 中使用 AsyncController 吗?

转载 作者:行者123 更新时间:2023-12-03 10:00:01 26 4
gpt4 key购买 nike

这个类有这样的描述:

Provided for backward compatibility with ASP.NET MVC 3.

来源只是:
public abstract class AsyncController : Controller
{
}

我在 MSDN 上找不到有关弃用此类的任何文档。我应该将 AsyncController 的使用替换为 Controller 吗?

最佳答案

Should I use AsyncController at ASP.NET MVC 4?



不。

Should I replace uses of AsyncController to Controller?



是的,异步操作在 asp.net-mvc 4 中以新方式实现,使用 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.



更多阅读在 Using Asynchronous Methods in ASP.NET MVC 4

关于asp.net-mvc - 我应该在 ASP.NET MVC 4 中使用 AsyncController 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13721571/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com