【问题标题】:Upload files over 2Gb to IIS 8 / ASP.NET 4.5?将超过 2Gb 的文件上传到 IIS 8 / ASP.NET 4.5?
【发布时间】:2012-02-17 22:23:42
【问题描述】:

我需要将 10Gb 文件一次性上传到 IIS。据我所知,IIS 7.x / ASP.NET 4.0 不支持超过 2Gb(有人说是 4Gb)的上传。

在 IIS 8 / ASP.NET 4.5 中是否已修复?

【问题讨论】:

  • 上传如何?使用input type="file"?
  • 使用 PUT 动词。使用 'input type="file"' 的 POST 分段上传也可以,Chrome 支持超过 2Gb 的上传。

标签: iis upload webdav large-files asp.net-4.5


【解决方案1】:

这是我上传低于 4GB 的方法(我也想知道如何打破这个限制): App pool 是 .NET 4.0 Classic 模式(为什么没有 4.5?)。网络配置:

<httpRuntime executionTimeout="2400" maxRequestLength="2099999999" />
...
<requestLimits maxAllowedContentLength="4294967290"/>

据本文http://msdn.microsoft.com/en-us/library/hh195435%28v=vs.110%29.aspx

public override Stream InputStream
{
    get
    {
        object workerRequest = ((IServiceProvider)HttpContext.Current).GetService(typeof(HttpWorkerRequest));
        bool webDevServer = workerRequest != null &&
                            workerRequest.GetType().FullName == "Microsoft.VisualStudio.WebHost.Request";

        if (request.GetType().Assembly.GetName().Version.Major >= 4 && !webDevServer)
        {
            try // trying to set disableMaxRequestLength true for .NET 4.5
            {
                return (Stream)typeof(HttpRequest).GetMethod("GetBufferlessInputStream", BindingFlags.Public | BindingFlags.Instance, null, new[] { typeof(bool) }, null)
                                        .Invoke(request, new object[] { true });
            }
            catch (NullReferenceException)
            { // .NET 4.0 is not patched by adding method overload
                Log(DateTime.Now + ": Can not invoke .NET 4.5 method");
            }
            return (Stream) typeof (HttpRequest).GetMethod("GetBufferlessInputStream",
                                                           BindingFlags.Public | BindingFlags.Instance,
                                                           null, new Type[0], null)
                                                .Invoke(request, new object[0]);
        }
        return request.InputStream;
    }
}

日志说 .NET 4.5 中的方法被毫无例外地调用。 但是这个链接http://aspnet.uservoice.com/forums/41199-general-asp-net/suggestions/2642879-maximum-upload-size-in-asp-net-is-2gb-increase-it 说:“已完成。这个限制在 4.5 中增加了。”

所以我只有一个问题:“如何?”

【讨论】:

  • 您上面提到的“requestLimits”元素有效地将 IIS 限制在 4GB。我们 (ASP.NET) 原型化并验证了一个补丁,该补丁将使我们的“maxRequestLength”限制为 64 位整数而不是 32 位整数,但由于硬编码的 IIS 上限,我们从未签入我们的补丁,因为它不会无论如何都非常有用。您调用的 GetBufferlessInputStream 重载是让 ASP.NET 忽略“maxRequestLength”限制的唯一方法。我们正在与 IIS 团队讨论,试图在未来的版本中取消硬编码上限。
  • @Levi 无需掀盖。只需将其删除。这个 2Gb/4Gb 的限制使 IIS/ASP.NET 在我们的项目中无法使用。我们的客户需要通过网络浏览器上传 10Gb 文件(是的,这是可能的)。
  • Mb 是否可以使用 owin 自托管环境?
  • 过去 7 年有没有人在这方面取得任何进展? ?
猜你喜欢
  • 2011-10-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-03
  • 1970-01-01
  • 2014-12-21
  • 2016-02-17
  • 1970-01-01
相关资源
最近更新 更多