Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Responce.Rederect with 2 session variables

Posted on 2011-09-16
6
Medium Priority
?
270 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Accepted Solution

by:
strickdd earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

773 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