我有一个用IHttpHandler编写的简单处理程序。我可以使它在IIS上工作吗?我遵循http://mvolo.com/developing-iis7-modules-and-handlers-with-the-net-framework/#handler的教程,但它不适合我。如何将IHttpHandler代码部署到IIS
在IIS7我的步骤:
我创建了一个名为 “SAMPLE”
从HandleMappings新的网页,我按下 “添加托管处理程序”
我的栏 - >请求路径:* .tm类型:SampleServer.MyHandler名称:MyHandler
尝试打开localhost/SampleServer.tm/
我收到此错误:MyHandler模块列表中无效的“ManagedPipelineHandler”模块。 错误代码:0x8007000d
Web.сonfig文件自动生成:
<?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()));
}
}
}
@Kirk Woll我编辑了我的文章。我确定我在IIS配置中做错了什么。 –
如果您尝试不使用结尾斜杠:“localhost/SampleServer.tm”,该怎么办? –
没有任何变化,它给出了同样的错误。 –