Solved

Responce.Rederect with 2 session variables

Posted on 2011-09-16
6
256 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

751 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