获取前一页的URL地址

PageLoad:

        if (!IsPostBack)
        {

            ViewState["UrlRef"] = HttpContext.Current.Request.UrlReferrer;
        }

 

ReturnButton:

 protected void btnReturn_Click(object sender, EventArgs e)
    {
        if (ViewState["UrlRef"] != null)
        {
            Response.Redirect(ViewState["UrlRef"].ToString());
        }
        else
        {
            Response.Redirect("~/Index.aspx");
        }

    }

 

posted @ 2012-01-19 11:47    阅读(1151)  评论(1编辑  收藏  举报