1

GitHub 上有 asp.net mvc 演示。不是完整的项目,而是控制器/类/活页夹。

我下载了他们的代码,有没有依赖演示和 jquery 演示的测试文件夹。

我还在他们的演示中制作了我的控制器/动作。

 public partial class UploadController : MyController
{
        [HttpPost]
        public ActionResult UploadFile(FineUpload upload, string extraParam1, int extraParam2)
        {
            // asp.net mvc will set extraParam1 and extraParam2 from the params object passed by Fine-Uploader

            var dir = @"e:\temp\";
            var filePath = Path.Combine(dir, upload.Filename);
            try
            {
                upload.SaveAs(filePath);
            }
            catch (Exception ex)
            {
                return new FineUploaderResult(false, error: ex.Message);
            }

            // the anonymous object in the result below will be convert to json and set back to the browser
            return new FineUploaderResult(true, new { extraInformation = 12345 });
        }
}

在他们的测试演示页面上,我将端点参数更改为

 endpoint: "http://localhost:60784/upload/uploadfile"

但是,嘿,我是如何得到异常的

A public action method 'uploadfile' was not found on controller     'MaNameSpace.Controllers.UploadController'.
4

1 回答 1

1

你可以做两件事:

  1. 尝试在端点 URL 中添加最后一个斜杠:http://localhost:60784/upload/uploadfile/

  2. 更改[HttpPost][HttpGet]并查看操作方法是否被命中。

在 Firefox 上使用 Firebug 在 Network 选项卡上打开,您可以查看向服务器发出的请求,并检查 File Upload 插件是否发出 Get 或 Post 请求。

于 2013-02-13T18:16:09.537 回答