Solved

Responce.Rederect with 2 session variables

Posted on 2011-09-16
6
245 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now