1

いくつかのhtmページを301リダイレクトする必要がありました。私はを介してそれをやろうとしていますHttpHandler。このウェブサイトは名前空間を使用していません。次のようにテストハンドラーを作成しました。

<%@ WebHandler Language="C#" Class="htmlhandler" %>

using System;
using System.Web;

public class htmlhandler : IHttpHandler {

    public void ProcessRequest (HttpContext context) {
        string url = HttpContext.Current.Request.Url.AbsoluteUri;
        context.Response.ContentType = "text/plain";
        context.Response.Write(url);
    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}

私はWeb.config次のようにハンドラーを登録しようとしました:

<httpHandlers>
  <add verb="*" path="*.htm" type="htmlhandler"/>
</httpHandlers>

しかし、次のエラーが発生します。

Parser Error Message: Could not load file or assembly 'htmlhandler' or one of its dependencies. The system cannot find the file specified.

助けてください。私のハンドラーはApp_Codeフォルダーに配置されていますが、それでもサーバーはそれを見つけることができません。

4

1 に答える 1

1

を使用してみてください<add verb="*" path="*.htm" type="htmlhandler, assemblyName"/>

また<system.webServer>、アプリプールを統合モードで実行している場合にのみ有効です。AppPoolを統合モードまたはクラシックモードのどちらで実行しているかを確認します。

于 2013-01-28T13:19:23.300 に答える