1、通过HttpModule防止SQL注入式攻击,适用于.net1.1程序
(1)新建类文件SqlHttpModule.cs,具体代码类似如下:
(2)在web.config文件中做以下配置
</system.web>
<httpModules>
<add name="SqlHttpModule" type="HttpModule.Class.SqlHttpModule, HttpModule" />
</httpModules>
</system.web>
2、通过httpHandlers防止SQL注入式攻击,适用于.net2.0及以上程序
(1)新建类文件SqlhttpHandlers.cs,具体代码类似如下:
(2)在web.config文件中做以下配置
</system.web>
<httpHandlers>
<add verb="*" path="*.aspx" type="httpHandlers.SqlhttpHandlers, httpHandlers"/>
</httpHandlers>
</system.web>