• ASP.NET中maxRequestLength和maxAllowedContentLength的区别;上传大文件设置IIS7文件上传的最大大小


    maxRequestLength表示ASP支持的最大请求大小,而maxAllowedContentLength指定IIS支持的请求中内容的最大长度。因此,要上传大文件,我们需要同时设置这两个参数:较小的那个“优先”,即最终支持上传的文件的大小根据maxRequestLength和maxAllowedContentLength中的较小值而定。
    如果文件长度小于maxAllowedContentLength但大于maxRequestLength,用户将获得标准(ASPX)错误页面。相反,用户会得到IIS错误页面。

    HTTP Error 404.13 - Not Found

    The request filtering module is configured to deny a request that exceeds the request content length.

    需要在web.config中配置如下:

    <system.web>

    <httpRuntime requestValidationMode="2.0" maxRequestLength="3072" ></httpRuntime>

    <!--单位:KB 3072=3MB 默认是4MB,最大支持2GB-->

    </system.web>

    <system.webServer>

    <security>
    <requestFiltering>
    <requestLimits maxAllowedContentLength="2147483648" />
    <!--单位:字节B 2147483648=2 GB 默认是4MB,最大支持2GB-->
    </requestFiltering>
    </security>

    </system.webServer>

    最后,需要注意的是,maxRequestLength的单位是KB,而maxAllowedContentLength的单位是字节,既然是请求,那么指的不仅仅是上传文件,只要是用户发送的请求,都可以通过上面的配置限制,比如Ajax请求服务器接口,参数内容超过了设置的最大长度就会请求失败!

  • 相关阅读:
    ARM汇编伪指令介绍.
    初识KITL
    c面试题
    Windows ce的体系结构和功能
    c宏定义的技巧总结
    Build in Windows Mobile
    关于wince注册表
    动态链接库(Dynamic Link Library)学习笔记
    WinCE驱动开发问题精华集锦
    OAL之系统时钟
  • 原文地址:https://www.cnblogs.com/canfengfeixue/p/16543232.html
Copyright © 2020-2023  润新知