0

IHttpHandler を使用して C# で記述された単純なハンドラーがあります。IIS で動作させるにはどうすればよいですか? http://mvolo.com/developing-iis7-modules-and-handlers-with-the-net-framework/#handlerのチュートリアルに従いましたが、うまくいきませんでした。

IIS7 で私の手順:

  1. 「SAMPLE」という新しいウェブページを作成します

  2. HandleMappings から、「マネージド ハンドラーの追加」を押しました。

  3. 列に入力します -> リクエスト パス: *.tm タイプ: SampleServer.MyHandler 名前: MyHandler

  4. 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()));
        }
    }
}
4

1 に答える 1