Skip to main content
 首页 » 编程设计

c#之在 Web.Config 中限制 URL 参数长度

2024年02月24日38qlqwjy

是否可以在 web.config 中添加某种限制来限制 URL 参数长度?我想尽早防止人们提交太大的 URL 参数,以便在有人试图用大的无效 URL 参数“攻击”服务器时,服务器不会受到不必要的负担。

请您参考如下方法:

请参阅以下链接:

http://learn.iis.net/page.aspx/143/use-request-filtering/

这是 IIS 7 配置的示例:

<configuration> 
    <system.webServer> 
        <security> 
            <requestFiltering> 
                <requestLimits 
                    maxAllowedContentLength="30000000" 
                    maxUrl="260" 
                    maxQueryString="25"/> 
            </requestFiltering> 
        </security> 
    </system.webServer>