user3247426
user3247426

Reputation: 127

how to navigate to different webpage from code behind

I have kept url of two page in two different session and from code behind I need to navigate to that page but I am not being able to do that.I have done like this:

if (Session["url"]!=null)
                {
                    string url = Session["url"].ToString();
                    //HyperLink obj = new HyperLink();

                    //HyperLink.NavigateUrl = piccom.displayLink(url);
                    Response.Redirect("url");
                    //HttpContext.Current.RewritePath("url");

                }
                else if (Session["url1"] != null)
                {
                    string url1 = Session["url1"].ToString();
                    Response.Redirect("url1");

                }
                else
                {
                    Response.Write("You havenot select the payment method");
                }

I am getting error that there is no page like this.

Upvotes: 1

Views: 857

Answers (1)

Satinder singh
Satinder singh

Reputation: 10198

It should be Response.Redirect(url) insetead of Response.Redirect("url"); remove ""

  if (Session["url"]!=null)
    {
     string url = Session["url"].ToString();
     Response.Redirect(url);
    }
    else if (Session["url1"] != null)
    {
        string url1 = Session["url1"].ToString();
        Response.Redirect(url1);
    }
    else{
       Response.Write("You havenot select the payment method");
    }

Upvotes: 2

Related Questions