Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 文件上载导致页面挂起_C#_Asp.net_Asp.net Mvc - Fatal编程技术网

C# 文件上载导致页面挂起

C# 文件上载导致页面挂起,c#,asp.net,asp.net-mvc,C#,Asp.net,Asp.net Mvc,当试图上传35兆的文件时,网站挂起 在调用File.SaveAs(path)命令之前,我在服务器端设置了一个断点 我在服务器端做了一次检查,以确保文件小于20兆,但它甚至没有达到这一点。网页将继续加载,直到我收到连接重置错误。在web.config中增加maxAllowedContentLength <system.webServer> <security> <requestFiltering> &

当试图上传35兆的文件时,网站挂起

在调用File.SaveAs(path)命令之前,我在服务器端设置了一个断点


我在服务器端做了一次检查,以确保文件小于20兆,但它甚至没有达到这一点。网页将继续加载,直到我收到连接重置错误。

在web.config中增加maxAllowedContentLength

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

如果使用简单的HTTP-POST上传文件,则需要等待整个文件上传。您不能在控制器中提前中止上载,只能按照Coset的回答使用web.config


您可以使用Flash检查客户端上的文件大小,但不知道有关详细信息,尽管在system.Web的Web.config中:

<httpRuntime maxRequestLength="100000"/> 


100000 KB=100 MB这是否是使用异步的好机会,如图所示

还有一篇关于async和Wait的优秀文章

抛开Web.Config问题不谈,这么大的文件需要一些时间。我会尽量不使用这样的操作来阻止当前线程