本番環境で正常に動作している .NET に ASP.NET Web サイトがあります。特定のダウンタイムでサーバーを頻繁にメンテナンスしています。したがって、ダウンタイム時にすべてのリクエストをメンテナンス中の Web ページにリダイレクトする機能が必要です。カスタム ハンドラーを使用してこのタスクを完了しましたが、顧客はそのソリューションに満足していません。代替ソリューションを提案してください。
私のカスタムハンドラーコードは次のとおりです
web.config の下に追加
<system.webServer>
<modules>
<add name="CustomModule" type="CustomModule"/>
</modules>
</system.webserver>
HTTP ハンドラの下に追加
public class CustomModule : IHttpModule
{
// In the Init function, register for HttpApplication
// events by adding your handlers.
public void Init(HttpApplication application)
{
application.EndRequest +=
(new EventHandler(this.Application_EndRequest));
}
}
ここにリダイレクトコードが入ります
private void Application_EndRequest(Object source, EventArgs e)
{
if (fileExtension.Equals(".aspx") == true && filePath.Contains("Contact.aspx") == false)
{
context.Response.Redirect("Contact.aspx");
}
}