我有一个用 IHttpHandler 用 c# 编写的简单处理程序。如何使它在 IIS 上工作?我按照http://mvolo.com/developing-iis7-modules-and-handlers-with-the-net-framework/#handler中的教程进行操作,但它对我不起作用。
在 IIS7 中,我的步骤:
我创建了一个名为“SAMPLE”的新网页
从 HandleMappings 我按下“添加托管处理程序”
我填写列 -> 请求路径:*.tm 类型:SampleServer.MyHandler 名称:MyHandler
尝试打开 localhost/SampleServer.tm/
我收到此错误:MyHandler 模块列表中的“ManagedPipelineHandler”模块无效。错误代码:0x8007000d
Web.сconfig 文件自动生成:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="MyHandler" path="*.tm" verb="*" type="SampleServer.MyHandler" resourceType="Unspecified" preCondition="integratedMode" />
        </handlers>
    </system.webServer>
</configuration>
我的 handler.cs 文件:
namespace SampleServer
{
    class MyHandler : IHttpHandler
    {
        public bool IsReusable
        {
            get { return false; }
        }
        public void ProcessRequest(HttpContext context)
        {
            DateTime dt = DateTime.Now;
            context.Response.Write(String.Format("<h1>{0}</h1>", dt.ToLongTimeString()));
        }
    }
}