反加载示例4代码不起作用。
public class FileUploadDerivedController : BackloadController
{
// Since version 1.9 you can call the asynchronous handler method
public async Task<ActionResult> FileHandler()
{
// Call base class method to handle the file upload asynchronously
ActionResult result = await base.HandleRequestAsync();
return result;
}
}我知道这个错误:
'Backload.Controllers.BackloadController' does not contain a definition for 'HandleRequestAsync'复制:
使用包管理器命令
Install-Package Backload使用
using Backload.Controllers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Backload;
using System.Threading.Tasks;控制器
// Change namespace to yours
namespace Backload.Examples.Example04.Controllers
{
// For all demos below open the file ~/Scripts/main.js and
// change the url of the ajax call for the fileupload plugin
// Demo 1: Derive from BackloadController and call the base class
public class FileUploadDerivedController : BackloadController
{
// Since version 1.9 you can call the asynchronous handler method
public async Task<ActionResult> FileHandler()
{
// Call base class method to handle the file upload asynchronously
ActionResult result = await base.HandleRequestAsync();
return result;
}
}
}此行应发生错误。
ActionResult result = await base.HandleRequestAsync();发布于 2013-12-14 03:29:19
错误是正确的。
带有异步CTP的VS2010不稳定,当然也不推荐用于生产。请注意,创建这个开发环境已经不容易了,因为异步CTP被许多Windows更新所阻止。
但是,即使您使用VS2012 (即与Microsoft.Bcl.Async一起使用),这仍然不能工作,因为 behavior is undefined on ASP.NET 4。
要在MVC上使用async,必须使用ASP.NET 4.5 (或更高版本),这意味着使用VS2012。
https://stackoverflow.com/questions/20579068
复制相似问题