0

私のasp.netページから、System.Web.HttpContext.Current.Response.Writeを使用してページを生成しています。完了したら、別のページにリダイレクトしたいと思います。うまくいきません。最後に Response.Redirect があった場合、ページを生成せずにすぐにリダイレクトします。部分的なコードを以下に示します。

string targetUrl = ConfigurationManager.AppSettings["URL"].ToString();


System.Web.HttpContext.Current.Response.Write(
"<form name='newForm' target='_blank' method=post action=" + targetUrl + " >");

System.Web.HttpContext.Current.Response.Write(
string.Format("<input type=text name=\"txtAcctNumber\" value=\"{0}\">",
                                  ViewState["GroupNumber"].ToString()));

System.Web.HttpContext.Current.Response.Write(
 string.Format("<input type=text name=\"txtAmountDue\" value=\"{0}\">",       txtAmountDue.Text));

 System.Web.HttpContext.Current.Response.Write("</form>");
 System.Web.HttpContext.Current.Response.Write("</body>");

 Response.Write("<SCRIPT LANGUAGE='JavaScript'>document.forms[0].submit();</SCRIPT>");
 Response.Clear();
 Response.Redirect("~/PremiumPayment/InvoiceSearch.aspx");

ありがとう

4

1 に答える 1

0

Response.Redirect によりThreadAbourException、クライアントに http 302 応答が送信されます。これは、即時のリダイレクトを目的としています。

ユーザーにメッセージを表示してからリダイレクトするには、メタ タグを使用する必要があります。

<meta http-equiv="refresh" content="10;URL=http://mysite/PremiumPayment/InvoiceSearch.aspx" />

これにより、ユーザーは 10 秒後に新しいページにリダイレクトされます。

于 2012-08-24T04:01:15.767 に答える