C# Web.config 配置handlers 和 httpHandlers

时间:2023-12-22 16:00:44

<system.web>

<httpHandlers>
<add verb="*" path="*.js.axd" type="Prolliance.ADManager.Web.ScriptTranslator" />
</httpHandlers>

</system.web>

<system.webServer>

<httpHandlers>
<add verb="*" path="*.js.axd" type="Prolliance.ADManager.Web.ScriptTranslator" />
</httpHandlers>

</system.webServer>

verb:表示访问方式如get,post,*表示任何方式

path:表示文件名称或以某种后缀结尾的文件

type:表示访问path文件时的处理类的名称空间完整路径

system.webServer 节中的某些设置只适用于 IIS 7.0 集成模式,而不适用于经典模式。具体而言,如果应用程序正在经典模式下运行,则会忽略 Web.config 文件的 system.WebServer 节中指定的所有托管代码模块和处理程序。与 IIS 的早期版本相同,托管代码模块和处理程序必须在 system.web 节的 httpModules 和 httpHandlers 元素中定义

注意如果IIS使用.net4.0以上版本的框架,<system.web>中的httpHandlers节点就没有用了,而应该使用微软专为4.0以上版本设计的新节点
<system.webServer>来配置ashx的handlers