简体   繁体   English

大文件无法在ASP.NET中上传

[英]Large file doesn't upload in ASP.NET

I have a asp.net web form app, i'm trying to upload a large file (13 mb) in a web form with a FileUpload control, when i press the submit button the web browser starts to upload the file. 我有一个asp.net Web表单应用程序,我正在尝试使用FileUpload控件在Web表单中上传大文件(13 mb),当我按下Submit按钮时,Web浏览器开始上传文件。 But, when the web browser finish the upload the app crash without reason, and doesn't lauch any exception, and not enter to the click event code (c#) of the submit button. 但是,当网络浏览器完成上载后,应用程序将无故崩溃,并且不会引发任何异常,也不会输入提交按钮的点击事件代码(c#)。 In my web.config i have set the maxAllowedContentLength option and the maxRequestLength option. 在我的web.config中,我设置了maxAllowedContentLength选项和maxRequestLength选项。

<system.webServer>
<security>
 <requestFiltering>
    <requestLimits maxAllowedContentLength="52428800" />
  </requestFiltering>
</security>

<httpRuntime targetFramework="4.5" executionTimeout="900" maxRequestLength="2097151" />

This is only happening in the web server(Windows Server 2012), in my local server this is not happening. 这仅在Web服务器(Windows Server 2012)中发生,而在我的本地服务器中则没有发生。 In the webserver show a default error (I don't manage the server, so i can't see what custom error is happening) 在网络服务器中显示默认错误(我不管理服务器,所以看不到正在发生的自定义错误)

i don't know why this is happening, because in the web server are apps with file upload options even more bigger. 我不知道为什么会这样,因为在Web服务器中,具有文件上传选项的应用程序甚至更大。

Thanks for your help. 谢谢你的帮助。

Modify your web.config by following Stricture, Here I'm using max File request length 13 MB & max Allowed Content Length 1 GB. 通过遵循Stricture修改web.config ,这里我使用的最大文件请求长度为13 MB,最大允许内容长度为1 GB。
Now change Behind the <system.web> in web.config 现在在web.config中的<system.web>后面进行更改

<httpRuntime targetFramework="4.5" maxRequestLength="13631488" executionTimeout="9000" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="1000" />

And Behind the <system.webServer> in web config write this Code 然后在Web配置的<system.webServer>后面编写此代码

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="1073741824" />
  </requestFiltering>
</security>

Thanks 谢谢

It looks like you're missing the opening "security" tag in your web.config 好像您在web.config中缺少打开的“ security”标签

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="52428800" />
        </requestFiltering>
    </security>
</system.webServer>

If your maxAllowedContentLength has a big value, your executionTimeout must be big, too! 如果您的maxAllowedContentLength值很大,那么您的executeTimeout也必须很大! It work in local because you don't need a long time to copy file in your hard. 它在本地工作,因为您不需要很长时间就可以将文件复制到硬盘中。 But when you upload your site in server, you need more executionTimeout. 但是,当您在服务器中上传站点时,您需要更多的executionTimeout。

the problem was a restriction on the server by the admin that doesn't allow upload large files. 问题是管理员限制了服务器,不允许上传大文件。 All the configuration given in this thread are correct. 该线程中给出的所有配置都是正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM