i made a page in my website, which redirects user to PAYPAL SANDBOX, and in return url i mentioned my page , which has IF ELSE conditions,
if (Session["blah blah"] == null ) then it will redirect user to error page else it will submit paid amount to database but it always execute NULL condition, why ?
here is my code :
protected void Page_Load(object sender, EventArgs e)
{
if (Session["tempSubAdmin"] == null)
{
Response.Redirect("wrongEmployerError.aspx");
}
else
{
String subAdminEmail = Session["tempSubAdmin"].ToString();
String conString = "Data Source=COSANOSTRA; MultipleActiveResultSets=true; Initial Catalog=Waleed_orsfinal;Integrated Security=True";
SqlConnection con = new SqlConnection(conString);
String query = "Update tblUser Set paid=1 where email='" + subAdminEmail + "'";
SqlCommand com = new SqlCommand(query, con);
try
{
con.Open();
com.ExecuteNonQuery();
}
catch (Exception exc)
{
Response.Write(exc.Message);
}
finally
{
con.Close();
}
}
and i have already created SESSION["tempSubAdmin"], in page which redirects user to PAYPAL sandbox site
Great you know it's null. Now you have to find out why, and that is why you have to debug. Find out where you set that variable and if it is null there or if it gets overwritten somewhere. There is no magic to this, just simple debugging
When you say it doesn't maintain session upon return, do you mean going out to paypal and then back to your site? If so then I wouldn't expect it to. A better choice may be cookies, or to look at amazon pdt to return a user to a site with some sort of tracking
variable so you know who they are.
Don't forget to mark useful responses as Answer if they helped you towards a solution.
Marked as answer by Chen Yu - MSFT on Dec 17, 2012 01:45 AM
Hunain Hafee...
Member
238 Points
639 Posts
page redirection to wrong page
Dec 09, 2012 04:59 PM|LINK
i made a page in my website, which redirects user to PAYPAL SANDBOX, and in return url i mentioned my page , which has IF ELSE conditions,
if (Session["blah blah"] == null ) then it will redirect user to error page else it will submit paid amount to database but it always execute NULL condition, why ?
here is my code :
protected void Page_Load(object sender, EventArgs e) { if (Session["tempSubAdmin"] == null) { Response.Redirect("wrongEmployerError.aspx"); } else { String subAdminEmail = Session["tempSubAdmin"].ToString(); String conString = "Data Source=COSANOSTRA; MultipleActiveResultSets=true; Initial Catalog=Waleed_orsfinal;Integrated Security=True"; SqlConnection con = new SqlConnection(conString); String query = "Update tblUser Set paid=1 where email='" + subAdminEmail + "'"; SqlCommand com = new SqlCommand(query, con); try { con.Open(); com.ExecuteNonQuery(); } catch (Exception exc) { Response.Write(exc.Message); } finally { con.Close(); } } and i have already created SESSION["tempSubAdmin"], in page which redirects user to PAYPAL sandbox sitejimbenson001
Member
120 Points
30 Posts
Re: page redirection to wrong page
Dec 09, 2012 05:09 PM|LINK
No way for us to answer this question. You have to use the debugger and find out why that session variable does not exist.
Vipindas
Contributor
5514 Points
810 Posts
Re: page redirection to wrong page
Dec 09, 2012 05:13 PM|LINK
Set a breakpoint in the above code and check whether Session["tempSubAdmin"] is null or not
Hunain Hafee...
Member
238 Points
639 Posts
Re: page redirection to wrong page
Dec 09, 2012 05:17 PM|LINK
it is null. i checked
jimbenson001
Member
120 Points
30 Posts
Re: page redirection to wrong page
Dec 09, 2012 05:23 PM|LINK
Great you know it's null. Now you have to find out why, and that is why you have to debug. Find out where you set that variable and if it is null there or if it gets overwritten somewhere. There is no magic to this, just simple debugging
oned_gk
All-Star
30991 Points
6344 Posts
Re: page redirection to wrong page
Dec 10, 2012 01:24 AM|LINK
Is PAYPAL sandbox site in current application? You can not use other site session. Create the session in your application.
Hunain Hafee...
Member
238 Points
639 Posts
Re: page redirection to wrong page
Dec 10, 2012 01:19 PM|LINK
yes, and i have used my site session but the problem is that it doesn't mainatin session upon return
markfitzme
Star
14319 Points
2215 Posts
Re: page redirection to wrong page
Dec 10, 2012 01:24 PM|LINK
When you say it doesn't maintain session upon return, do you mean going out to paypal and then back to your site? If so then I wouldn't expect it to. A better choice may be cookies, or to look at amazon pdt to return a user to a site with some sort of tracking variable so you know who they are.
Hunain Hafee...
Member
238 Points
639 Posts
Re: page redirection to wrong page
Dec 10, 2012 06:21 PM|LINK
yes exactly