【问题标题】:Pdf and doc files uploading issuepdf和doc文件上传问题
【发布时间】:2014-03-21 10:28:17
【问题描述】:
我在 MVC 中有一个文件上传控件,即输入类型文件。我的第一个问题是
如果我正在上传文件,则需要的时间太长。我试图上传一个 4.2 Mb 的文件。当我计算时间时,它会在 3 分钟后自动停止操作,但在那之前文件也没有上传。
我的 web.config 文件中有这个设置::
<httpRuntime targetFramework="4.5" maxRequestLength="10240" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
- 为什么上传时间太长,因为这是一个简单的上传代码?
- 我想将应用程序超时设置为最大值。如何设置?
【问题讨论】:
标签:
c#
asp.net
.net
asp.net-mvc
asp.net-mvc-3
【解决方案1】:
1.为什么上传时间太长,因为这是一个简单的上传代码?
您的主机或客户端可能存在带宽限制。带宽可能是上传缓慢的主要原因。
如果带宽没有问题,那么您可以得到一些帮助here。
2。我想将应用程序超时设置为最大值。如何设置?
您可以在 webconfig 中将最大上传大小和超时设置为:
<system.web>
<httpRuntime maxRequestLength="10240" executionTimeout="360"/>
</system.web>
最大请求长度以千字节为单位,执行超时以秒为单位。
【解决方案2】:
添加到system.web
<system.web>
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
</system.web>
进入 system.webServer
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>