上传文件http处理程序文件大小

时间:2011-11-04 03:28:08

标签: c# asp.net

我正在创建一个小型Silverlight上传器。它做两件事:检查文件大小和类型并上传文件。我正在接收端创建一个http处理程序。但是,Silverlight代码仍然可以被操纵或绕过,我不想绑定服务器,因为有人正在上传100MB文件。如何在http处理程序中限制上载的大小,以便在部分上载的文件大小超过3MB时停止上载。

感谢您的建议。

2 个答案:

答案 0 :(得分:0)

默认情况下,IIS already limits the max file size to 4MB。您可以通过修改web.config元素在<httpRuntime>中更改此内容:

<httpRuntime maxRequestLength="8192" />

这会将其设置为8MB。

答案 1 :(得分:0)

在web.config上设置最大请求长度为3MB

<configuration>
  <system.web>
  <httpRuntime maxRequestLength="3000"
    enable = "True"
    requestLengthDiskThreshold="512"
    useFullyQualifiedRedirectUrl="True"
    executionTimeout="45"
    versionHeader="1.1.4128"/>
  </system.web>
</configuration>

Documentation here.