教程集 www.jiaochengji.com
教程集 >  脚本编程  >  Asp.net  >  正文 404 – File or directory not found 的解决方法

404 – File or directory not found 的解决方法

发布时间:2015-10-23   编辑:jiaochengji.com
错误提示:Server Error 404 – File or directory not found.

错误提示
Server Error
404 – File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

上传一个大小约为160MB的文件至服务器,出现以上错误提示。
把上传文件于本机测试没有问题。但上传至服务器时,这个错误产生了。

本地可以,服务器却Error。可以肯定程序代码没有问题,怎样说呢?
测试尝试上传另一个相同的文件格式,只是大小有所改变,大小约为25MB,它即能成功上传了。

Insus.NET检查了web.config文件,可以上传的文件限制已经设置相当大了200MB。

复制代码 代码如下:
<system.web>  
    <httpRuntime maxRequestLength="204800" useFullyQualifiedRedirectUrl="true" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="true" executionTimeout="6000" />
  </system.web>

问题出现在什么地方呢?

找到资料,原来IIS 的maxAllowedContent Length的缺省值为30000000 bytes. 上传大于这个长度的数据流被截断,导致文件或目录找不到。

因此Insus.NET尝试在web.config更改这个设置,添加下面节点:

复制代码 代码如下:
<system.webServer>   
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2097152000" maxQueryString="5000" maxUrl="8000"></requestLimits>
      </requestFiltering>
    </security>
  </system.webServer>

测试上传200MB的文件,没有问题。

您可能感兴趣的文章:
404 – File or directory not found 的解决方法
.htaccess 规则
ASP.NET中设置404页面并输出404状态代码
php header 404跳转错误页面实例
php header头信息应用举例
解决:failed to open stream: No such file or directory in
php 定义404页面的方法
Centos安装libxml2 'bin/rm: cannot remove libtoolT'...的解决方法
php header 404错误包含文件出现乱码解决办法
访问php报404错误的原因

[关闭]
~ ~