如何从其他页面返回页面?

时间:2014-03-03 09:39:39

标签: asp.net

我已经调用了一个重定向到另一个页面的方法。完成另一个页面后,我想从上一页回来。这是我的代码:

private string RedirectToPaymentGateway_v3(string MTrackid, string MAmount,string MSType)
{
    HttpContext.Current.Session["pgMTrackid"] = MTrackid;
    HttpContext.Current.Session["pgMAmount"] = MAmount;
    HttpContext.Current.Session["pgMStype"] = MSType;
    HttpContext.Current.Response.Redirect("DoPost.asp", true);

    return "";
}

完成dopost.asp后,我想在我调用DoPost.asp的页面中返回。

1 个答案:

答案 0 :(得分:0)

将原始页面作为参数传递,然后重定向到它:

private string RedirectToPaymentGateway_v3(string MTrackid, string MAmount,string MSType)
{
    HttpContext.Current.Session["pgMTrackid"] = MTrackid;
    HttpContext.Current.Session["pgMAmount"] = MAmount;
    HttpContext.Current.Session["pgMStype"] = MSType;
    HttpContext.Current.Response.Redirect("DoPost.asp?ReturnUrl=" + 
Server.UrlEncode(Request.Url.ToString());

    return "";
}

然后在DoPost.asp中处理完

Response.Redirect(Server.UrlDecode(Request.Querystring["ReturnUrl"]));