通过2Gb上传文件到IIS 8/ASP.NET 4.5?

IT *_*DAV 8 iis upload webdav large-files asp.net-4.5

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

它是在IIS 8/ASP.NET 4.5中修复的吗?

Tar*_*ski 6

这是我如何上传4GB以下(我想知道如何打破这个限制):App池是.NET 4.0经典模式(为什么没有4.5?).web.config中:

<httpRuntime executionTimeout="2400" maxRequestLength="2099999999" />
...
<requestLimits maxAllowedContentLength="4294967290"/>
Run Code Online (Sandbox Code Playgroud)

根据这篇文章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;
    }
}
Run Code Online (Sandbox Code Playgroud)

Log表示从.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团队进行讨论,试图在未来的版本中解除硬编码上限. (3认同)
  • @Levi没有必要抬起帽子.只需删除它.这种2Gb/4Gb限制使IIS/ASP.NET在我们的项目中无法使用.我们的客户需要通过网络浏览器上传10Gb文件(是的,这是可能的). (2认同)