0

我有一个 .NET 4.5 MVC 5 Web 应用程序,它利用 Backload 2.0 帮助上传 Excel 文件。控制器方法在我的开发环境中效果很好。但是,当我移至生产服务器时,同样的方法现在失败了。

它失败了,因为它handler.Services.POST是空的。所有其他属性 offhandler.Services也为 null,例如GET等。

什么可能导致这种情况发生?它是IIS设置吗?网络配置?我还能检查什么?

大部分代码都是从 Backload 附带的示例中复制的。

        [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post | HttpVerbs.Put | HttpVerbs.Delete | HttpVerbs.Options)]
        public async Task<ActionResult> FileHandler()
        {
            try
            {
                // Create and initialize the handler
                var handler = Backload.FileHandler.Create();
                handler.Init(HttpContext.Request);

                // Call the appropriate request handlers
                if (handler.Context.HttpMethod == "POST")
                {
                    // Get the posted file with meta data from the request
                    handler.FileStatus = await handler.Services.POST.GetPostedFiles();

                    if (handler.FileStatus != null)
                    {
                        var file = handler.FileStatus.Files[0];

                        DateTime spreadsheetDate;

                        using (var memoryStream = new MemoryStream((int)file.FileSize))
                        {
                            await file.FileStream.CopyToAsync(memoryStream);

                            //TODO: do some stuff...
                        }
                    }

                    // Create client plugin specific result and return an ActionResult
                    IBackloadResult result = handler.Services.Core.CreatePluginResult();
                    return ResultCreator.Create((IFileStatusResult)result);
                }

                // other http methods may also be handled
                return new EmptyResult();
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError);
            }
        }
4

1 回答 1

0

直接 api 调用(服务命名空间)是专业版功能,仅适用于专业版。

在您的情况下,我认为您可以切换到具有相同结果的事件。例如,您可以使用StoreFileRequestStarted事件。不要忘记在 Web.Backload.config 中启用事件,如下所述: https ://github.com/blackcity/backload/wiki/Example-12

演示包还包括一个事件示例: https ://github.com/blackcity/Backload/releases/download/v2.1.0.0/Backload.Standard.2.1.Full.zip

于 2015-12-01T15:11:39.513 回答