use*_*998 4 c# asp.net iis-7 file-upload windows-server-2008-r2
我们的 ASP.NET C# web 应用程序在以下环境中使用 - .NET Framework 4 - IIS 7 - Windows 2008 - Visual Studio 2010 .NET IDE - C# - HTTPS (SSL) 我们的 ASP.NET C# web 应用程序上传各种文件,如 jpgs , mp4, mp3, pngs, docx, txt 等文件复制到名为 ClientBin 的文件夹中。但是,如果我们将应用程序部署到 IIS7 服务器,我们必须授予我们应用程序的 Web 用户上传文件的权限。我们授予 \IIS_IUSRS 组在我们的 ClientBin 上传文件夹上执行、读取、写入和执行的权限。
Web 用户可以上传小于大约 12MB 的文件。
但是,当 Web 用户上传超过大约 12MB 的文件时,上传的文件在服务器的 ClientBin 上传文件夹中将为 0 字节。
在我们的 Web.config 中,我们对 httpRuntime 标签进行了以下配置:
<system.web>
...
.....
........
..............
<httpRuntime maxRequestLength="1048576" executionTimeout="50000"
useFullyQualifiedRedirectUrl="false" requestLengthDiskThreshold="15360"
minFreeThreads="8" minLocalRequestFreeThreads="4"
appRequestQueueLimit="100" />
</system.web>
Run Code Online (Sandbox Code Playgroud)
在我们的 Web.config 中,我们有以下requestLimits标签配置:
<system.webServer>
..............
.........................
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2000000000" />
<fileExtensions>
<add fileExtension=".aspx" allowed="true" />
</fileExtensions>
</requestFiltering>
</security>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
我还通过创建以下设置采用了修改 machine.config 文件的不受欢迎的方法:
<system.web>
<processModel responseDeadlockInterval="0:09:00"
responseRestartDeadlockInterval="0:09:00" />
.....................
..........................................
.............................................................
</system.web>
Run Code Online (Sandbox Code Playgroud)
我还采取了以下步骤: 我检查了事件查看器和 IIS 日志,但没有显示奇怪。
大小小于大约 12 MB 的文件可以正确上传。
重要的是要注意文件确实会上传,但最终都是 0Kb。上传的文件名和类型与我桌面上的相同,但大小为 0Kb。我桌面上的那个大约是 75MB。
ASP.NET 和 IIS 不会抛出任何错误页面。
为什么上传到 ASP.NET Web 应用程序的大于 12MB 的文件显示为 0MB?
尝试增加requestLengthDiskThreshold匹配maxRequestLength
<configuration>
<system.web>
<!-- maxRequestLength and requestLengthDiskThreshold is in Kilobytes-->
<httpRuntime maxRequestLength="204800" requestLengthDiskThreshold="204800" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<!-- maxAllowedContentLength is in Bytes not Kilobytes -->
<requestLimits maxAllowedContentLength="204800000" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
另外,您是否尝试过使用更全面的 ASP.NET 上传控件,例如Telerik RadUpload模块?它可以免费试用,看看它是否能解决您的问题。
| 归档时间: |
|
| 查看次数: |
3291 次 |
| 最近记录: |