首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Backload Example#4在VS2010 MVC4中不工作

Backload Example#4在VS2010 MVC4中不工作
EN

Stack Overflow用户
提问于 2013-12-14 02:34:01
回答 1查看 560关注 0票数 0

反加载示例4代码不起作用。

代码语言:javascript
复制
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;
    }
}

我知道这个错误:

代码语言:javascript
复制
'Backload.Controllers.BackloadController' does not contain a definition for 'HandleRequestAsync'

复制:

  • 使用VS2010,打开新的MVC4项目。
  • 要在VS2010中启用异步,请安装VS异步CTP:http://www.microsoft.com/en-us/download/details.aspx?id=9983
  • 在您的项目中,参考: VS异步CTP安装\Microsoft异步CTP\Samples\AsyncCtpLibrary.dll

使用包管理器命令

代码语言:javascript
复制
Install-Package Backload

使用

代码语言:javascript
复制
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;

控制器

代码语言:javascript
复制
// 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;
        }
    }
}

此行应发生错误。

代码语言:javascript
复制
ActionResult result = await base.HandleRequestAsync();
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20579068

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档