いくつかの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
フォルダーに配置されていますが、それでもサーバーはそれを見つけることができません。