会话变量值变为null写入Response.Write(“REDIRECT = xxx”)后

时间:2013-07-11 10:36:24

标签: asp.net c#-3.0

我有一个处理支付网关响应的页面,PaymentReturn.aspx。在这个页面中,我正在记录响应并将响应存储到会话变量中,并将此会话变量用于处理发票页面的另一页Invoice.aspx ...所以在PaymentReturn页面中,我有

Session["ResponseOfPayment"] =  paymentResonse as PaymentResponse; // PaymentResonse is class

Response.Write("REDIRECT=http://mydomain.com/Invoice.aspx");

在Invoice.aspx中我有,

PaymentResponse  paymentResonse = Session["ResponseOfPayment"] as PaymentResponse;

if(paymentResponse!=null)
{
  // Generate Invoice
}

但是我收到了PaymentResonse实例null ..这有什么问题?

1 个答案:

答案 0 :(得分:0)

使用Response.Redirect而不是Response.Write。

Response.Redirect("Invoice.aspx");