Solved

Responce.Rederect with 2 session variables

Posted on 2011-09-16
6
252 Views
Last Modified: 2012-06-21
Okay first part done now I need to add 2 variables to my session state for this pop up.


protected void Button2_Click(object sender, EventArgs e)
        {
//The first session and responce.redirect works fine 
//first session
            Session["SessionParkID"] = dltName.SelectedValue;
            first// respnce
       //     Response.Redirect("/ics/Portlets/CUS/ICS/PARK_GradeAppeal_v1_5_27_2011/Downloads.aspx?ID=" + Session["SessionParkID"].ToString(), "_PDF", "menubar=0,width=100,height=100");
//added a second variable to the mix
Session["ProcSes"] = "P_sp_GrabDoc1";
//this is the new responce.redirect the page loads but the pop up does not... anyone got any ideas?
            Response.Redirect("/ics/Portlets/CUS/ICS/PARK_GradeAppeal_v1_5_27_2011/Downloads.aspx?ID=" + Session["SessionParkID"].ToString() + Session["ProcSes"].ToString(), "_PDF", "menubar=0,width=100,height=100");

Open in new window

protected void Page_Load(object sender, EventArgs e)
        {
            testinglablesession.Text = Request.QueryString["ID"].ToString();

            lblDownloadNumber.Text = Request.QueryString["ProcSes"].ToString();
}

Open in new window

0
Comment
Question by:HawaiiDragon
  • 3
  • 2
6 Comments
 
LVL 28

Expert Comment

by:strickdd
ID: 36550588
Once the first "Response.Redirect" is hit, all other code is useless. It won't get processed and will never take affect. A Response.Redirect will IMMEDIATELY send the current process to the page you specify. If you want both sessions set you will have to do:

Session["SessionParkID"] = dltName.SelectedValue;
Session["ProcSes"] = "P_sp_GrabDoc1";

Response.Redirect(...);

Open in new window


I don't think this is what you want because you are trying to prompt for two downloads, this is not possible the way you are trying. As mentioned about the first response.redirect will take affect and the second will NEVER be hit.

You have several options if you need multiple downloads...
1) Zip the downloads together and send them as one ZIP file download
2) Open new browser windows on the click action that starts this process (i.e. <a href="..." target="_blank">First Download</a>). This requires two links to be clicked.
0
 

Author Comment

by:HawaiiDragon
ID: 36550636
I have played with it more but I am not trying to do two downloads at once just a little more specifice in my string.

From the code below it hits my first responce redirect string fine if I only have one session variable and Save the session variable but form sone reason when I add he second it does not want to save it....

Am I doing something wrong in my response.redirect query string?

//original
           // Response.Redirect("/ics/Portlets/CUS/ICS/PARK_GradeAppeal_v1_5_27_2011/Downloads.aspx?ID=" + Session["SessionParkID"].ToString(), "_PDF", "menubar=0,width=10000,height=10000");
          //trial
            Response.Redirect("/ics/Portlets/CUS/ICS/PARK_GradeAppeal_v1_5_27_2011/Downloads.aspx?ID=" + Session["SessionParkID"].ToString() +"&Proc="+ Session["ProcSes"].ToString(), "_PDF", "menubar=0,width=10000,height=10000");

Session["SessionParkID"] = dltName.SelectedValue;
            label2.Text = "P_sp_GrabDoc1";
            Session["ProcSes"] = label2.Text;
            //original
           // Response.Redirect("/ics/Portlets/CUS/ICS/PARK_GradeAppeal_v1_5_27_2011/Downloads.aspx?ID=" + Session["SessionParkID"].ToString(), "_PDF", "menubar=0,width=10000,height=10000");
          //trial
            Response.Redirect("/ics/Portlets/CUS/ICS/PARK_GradeAppeal_v1_5_27_2011/Downloads.aspx?ID=" + Session["SessionParkID"].ToString() +"&Proc="+ Session["ProcSes"].ToString(), "_PDF", "menubar=0,width=10000,height=10000");

Open in new window

0
 

Author Comment

by:HawaiiDragon
ID: 36550644
forgot the downolad page code...

 public partial class Downloads : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            testinglablesession.Text = Request.QueryString["ID"].ToString();
            lblDownloadNumber.Text = Request.QueryString["ProcSes"].ToString();
}
}
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 28

Accepted Solution

by:
strickdd earned 500 total points
ID: 36550702
Ok, it makes a little more sense. My first question is: why are you setting session variable and then adding those to the query string? You should be able to access the session variables on the download page without the need for the querystring:

public partial class Downloads : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
//Check for null sessions here otherwise errors can occur
            testinglablesession.Text = Session["SessionParkID"].ToString();
            lblDownloadNumber.Text = Session["ProcSes"].ToString();
}
} 

Open in new window


Next question, if you need the querystring, what set the session?

Session["SessionParkID"] = dltName.SelectedValue;
            label2.Text = "P_sp_GrabDoc1";
            
Response.Redirect("/ics/Portlets/CUS/ICS/PARK_GradeAppeal_v1_5_27_2011/Downloads.aspx?ID=" + dltName.SelectedValue +"&Proc="+ label2.Text, "_PDF", "menubar=0,width=10000,height=10000"); 

Open in new window


Lastly, make sure to step through your code and make sure that the values exist, easiest way:

Session["SessionParkID"] = dltName.SelectedValue;
            label2.Text = "P_sp_GrabDoc1";
      String temp = "/ics/Portlets/CUS/ICS/PARK_GradeAppeal_v1_5_27_2011/Downloads.aspx?ID=" + dltName.SelectedValue +"&Proc="+ label2.Text;

Response.Redirect(temp, "_PDF", "menubar=0,width=10000,height=10000"); 

Open in new window

0
 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
ID: 36550801
Hello,

protected void Page_Load(object sender, EventArgs e)
        {
            testinglablesession.Text = Request.QueryString["ID"].ToString();

            lblDownloadNumber.Text = Request.QueryString["ProcSes"].ToString();
}

testinglablesession.Text = Request.QueryString["ID"].ToString() '" +',' + "'
Request.QueryString["ProcSes"].ToString(); //In C#


testinglablesession.Text = Request.QueryString("ID").ToString() & "," &
Request.QueryString("ProcSes").ToString(); //In VB
0
 

Author Closing Comment

by:HawaiiDragon
ID: 36550890
and your awesome!!!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question