IHttpHandlerFactory を「すべての」http リクエストにマップしました。
<httpHandlers>
<add verb="*" path="*.*" type="HomeController"/>
</httpHandlers>
ホーム コントローラーから、別の HTTP コントローラーを呼び出します。
一部のコントローラーは、ユーザーを別の .aspx ファイルにリダイレクトする必要があります。
問題: これにより、homecontroller (ファクトリ) が再び起動され、無限ループで呼び出されます。
工場コード
public class HomeController : IHttpHandlerFactory
{
public HomeController()
{
}
public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
{ ....
return new HelloWorldHandler2();
....
}
public void ReleaseHandler(IHttpHandler handler)
{
if (this.handler.Equals(handler))
{
this.handler.busy = false;
}
//throw new NotImplementedException();
}
ハンドラー コード
public class HelloWorldHandler2 : IHttpHandler
{
public HelloWorldHandler2()
{
}
public bool busy = false;
public void ProcessRequest(HttpContext context)
{
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
// This handler is called whenever a file ending
// in .sample is requested. A file with that extension
// does not need to exist.
//Response.Write("<html>");
//Response.Write("<body>");
//Response.Write("<h1>backup handler</h1>" );
//Response.Write("</body>");
//Response.Write("</html>");
context.Handler = this;
Response.Redirect("About.aspx");
}
public bool IsReusable
{
// To enable pooling, return true here.
// This keeps the handler in memory.
get { return false; }
}
}
ご覧のとおり、ファクトリがハンドラを呼び出し、ハンドラがページをリダイレクトし、リダイレクトが再びファクトリを呼び出します...