Solved

Responce.Rederect with 2 session variables

Posted on 2011-09-16
6
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

627 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