【发布时间】:2016-03-05 11:37:22
【问题描述】:
我有一个 .NET 4.5 MVC 5 Web 应用程序,它利用 Backload 2.0 帮助上传 Excel 文件。控制器方法在我的开发环境中效果很好。但是,当我转移到生产服务器时,同样的方法现在失败了。
它失败了,因为handler.Services.POST 为空。 handler.Services 之外的所有其他属性也为空,例如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);
}
}
【问题讨论】:
标签: c# .net asp.net-mvc backload