ユーザーが請求書を支払う必要があるかどうかを処理するカスタムHttpModuleがあります。ユーザーがポストバックを作成したが、HttpModuleの請求書セクションで「キャッチ」された場合、請求書の支払い後にユーザーが作成した元のポストバックを再投稿したいので、ユーザーは開始する必要はありません。以上。
例:
- ユーザーがフォームに入力してサーバーに送信する
- HttpModuleは、ユーザーに未払いの請求書があることを識別し、ユーザーを支払いページにリダイレクトします
- ユーザーが請求書を支払う
- ポイント1からの元の投稿が再投稿され、ユーザーは続行できます
HttpContext(HttpContext.Currentから)をセッション状態で保存し、請求書が支払われたときにHttpContext.Currentをセッションの値に設定しようとしましたが、機能しません。
HttpModuleが通常のフローを中断した後、ポストバックを再利用することは可能ですか?
私のHttpModuleは次のようになります。classUnpaidInvoiceHttpModule:IHttpModule {private HttpApplication cHttpApp;
public void Dispose(){}
public void Init(HttpApplication context)
{
cHttpApp = context;
context.PreRequestHandlerExecute += new EventHandler(CheckForUnpaidInvoices);
}
private void CheckForUnpaidInvoices(Object s, EventArgs e)
{
if (HttpContext.Current.Request.Path.EndsWith(".aspx") || HttpContext.Current.Request.Path.EndsWith(".asp") || HttpContext.Current.Request.Path == "/")
{
if (HttpContext.Current.Request.Path != "/login.aspx"
&& HttpContext.Current.Request.Path != "/Payment/Default.aspx"
&& HttpContext.Current.Request.Path != "/Payment/Default_notice.aspx"
&& HttpContext.Current.User != null)
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
CustomUser mUser = ManagerSecurity.SecurityAPI.GetUser();
if (mUser.HasUnpaidInvoices)
{
HttpContext.Current.Session["prepaymentHttpContext"] = HttpContext.Current;
HttpContext.Current.Response.Redirect("/Payment/Default.aspx");
}
else
{
if (HttpContext.Current.Session["prepaymentHttpContext"] != null)
{
HttpContext.Current = (HttpContext)HttpContext.Current.Session["prepaymentHttpContext"];
}
}
}
}
}
}
}