【发布时间】:2011-04-05 08:34:42
【问题描述】:
我正在尝试让自定义 HttpHandler 在我的示例 Web 应用程序中工作。我遇到了很多问题,但最终遇到了错误 500。应用程序池正在经典 ASP.NET 2.0 模式下运行。服务器是 IIS 7.5,操作系统是 Win 7 Pro。
这是我的处理程序的代码:
public class SampleHandler : IHttpHandler
{
public SampleHandler()
{
}
public bool IsReusable
{
get
{
return true;
}
}
public void ProcessRequest(HttpContext context)
{
context.Response.Clear();
context.Response.ContentType = "text/html";
context.Response.Write("This is a sample content.");
context.Response.Expires = 0;
context.Response.End();
}
}
这是一个web.config文件内容:
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="*.shc" type="SampleHandler"/>
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<add resourceType="Unspecified" verb="*" path="*.shc" name="SampleHandler" type="SampleHandler" modules="IsapiModule" scriptProcessor="c:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll\aspnet_isapi.dll"/>
</handlers>
</system.webServer>
</configuration>
这里是错误截图的链接:http://bit.ly/cmPk4i
谁能告诉我我做错了什么?提前致谢!
【问题讨论】:
标签: asp.net configuration iis-7 httphandler