I have a page called "AdminLogin.aspx", this is where the users log in. If they enter the correct credentials, I set these 2 session variables and do a Respond.Redirect():
Then in my AdminPage.aspx, I have a GridView. In this gridview i have a column with applicant names. Once a name is clicked, a function is ran that creates a LocalReport from an RDLC file. Then I populate the rdlc with a datasource. Once it is populated "behind the scenes", I do this:
//------- CREATE PDF locally for email, save in InjuryReports directory ---------------------//
byte[] pdfContent = report.Render("PDF", null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
//--------- TESTING FOR PDF IMMEDIATE OUTPUT (won't need localreport if doing this way -------------
MemoryStream stream = new MemoryStream(pdfContent);
Response.ContentType = "application/pdf";
Response.BinaryWrite(stream.ToArray());
This is working just fine. Now, when the PDF is shown, the URL DOES NOT change, it stays on AdminPage.aspx. When I click the back button, after selecting the FIRST PDF to be shown, it goes back to the GridView in my AdminPage.aspx just fine. However, if I select another name, that applicant's "PDF"/RDLC is shown and if I click the back button again, it takes me to the website I was before this website.
Like this: (Start)GOOGLE -> AdminLogin.aspx -> AdminPage.aspx - PDF - AdminPage.aspx - PDF -> GOOGLE.
I check to see if the user is logged in at the begining of my AdminPage.aspx like so:
if(Session["access"] != "granted")
Response.Redirect("AdminLogin.aspx");
if(Session["department"] == "access")
set some variables
Any ideas on why this sends me back to Google, or whatever previous page I was on BEFORE i went to AdminLogin.aspx. Thank you so much, I have been driving myself insane with this one.
This does this in every browser. IE 7-9, Chrome and FF (dont have Safari)
Do you mean the Back Button on the browser? This really shouldn't be part of your workflow because it bypasses the page lifecycle. This problem is further confused when you set session data to have some semblence of a sequence of operations. You should,
instead, have an actual button on the page that reloads the AdminPage.aspx so that the Page_Load can fill in the gridview again.
"Dream as if you'll live forever, live as if you'll die today." --James Dean
Yes I mean the back button on the browser. How can you show a "dynamic RDLC" report with a custom back button when the browser renders it as a PDF? I can't think of another way to get it to work. Please excuse my ignorance. The GridView loads fine the first
time the user comes back from the "PDF" page to the AdminPage.aspx, but not the second time.
Is your insistence on not having the PDF render to a different page by design? It seems to me that if a user clicked on a row in the GridView, you could capture that element in Session and Redirect to a third aspx page that is responsible for rendering
the PDF. Then, even if you do hit back, it would go back to the page specifically concerned with generating the GridView.
"Dream as if you'll live forever, live as if you'll die today." --James Dean
Marked as answer by gvinson89 on Jul 07, 2012 12:01 AM
I figured it out, thank you both for your suggestions.
SOLUTION:
First off, I did not create this app, I am updating/fixing it, I have been thrown to the wolves so to speak. It looks like the old code that redirected the user to a new page was...
Response.Write(@"<script type='text/javascript'>window.open('ViewReport.aspx?id=" + id + "');</script>");
gvinson89
Member
2 Points
7 Posts
Session Variables and Response.Redirect()
Jul 06, 2012 09:57 PM|LINK
Hey everyone,
I have a page called "AdminLogin.aspx", this is where the users log in. If they enter the correct credentials, I set these 2 session variables and do a Respond.Redirect():
Session["access"] = "granted"; Session["department"] = "access"; Response.Redirect("AdminPage.aspx", false);Then in my AdminPage.aspx, I have a GridView. In this gridview i have a column with applicant names. Once a name is clicked, a function is ran that creates a LocalReport from an RDLC file. Then I populate the rdlc with a datasource. Once it is populated "behind the scenes", I do this:
//------- CREATE PDF locally for email, save in InjuryReports directory ---------------------// byte[] pdfContent = report.Render("PDF", null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); //--------- TESTING FOR PDF IMMEDIATE OUTPUT (won't need localreport if doing this way ------------- MemoryStream stream = new MemoryStream(pdfContent); Response.ContentType = "application/pdf"; Response.BinaryWrite(stream.ToArray());This is working just fine. Now, when the PDF is shown, the URL DOES NOT change, it stays on AdminPage.aspx. When I click the back button, after selecting the FIRST PDF to be shown, it goes back to the GridView in my AdminPage.aspx just fine. However, if I select another name, that applicant's "PDF"/RDLC is shown and if I click the back button again, it takes me to the website I was before this website.
Like this: (Start)GOOGLE -> AdminLogin.aspx -> AdminPage.aspx - PDF - AdminPage.aspx - PDF -> GOOGLE.
I check to see if the user is logged in at the begining of my AdminPage.aspx like so:
if(Session["access"] != "granted") Response.Redirect("AdminLogin.aspx"); if(Session["department"] == "access") set some variablesAny ideas on why this sends me back to Google, or whatever previous page I was on BEFORE i went to AdminLogin.aspx. Thank you so much, I have been driving myself insane with this one.
This does this in every browser. IE 7-9, Chrome and FF (dont have Safari)
rdlc Session Redirect backbutton
AceCorban
Star
12318 Points
2269 Posts
Re: Session Variables and Response.Redirect()
Jul 06, 2012 10:24 PM|LINK
Do you mean the Back Button on the browser? This really shouldn't be part of your workflow because it bypasses the page lifecycle. This problem is further confused when you set session data to have some semblence of a sequence of operations. You should, instead, have an actual button on the page that reloads the AdminPage.aspx so that the Page_Load can fill in the gridview again.
gvinson89
Member
2 Points
7 Posts
Re: Session Variables and Response.Redirect()
Jul 06, 2012 11:35 PM|LINK
Yes I mean the back button on the browser. How can you show a "dynamic RDLC" report with a custom back button when the browser renders it as a PDF? I can't think of another way to get it to work. Please excuse my ignorance. The GridView loads fine the first time the user comes back from the "PDF" page to the AdminPage.aspx, but not the second time.
AceCorban
Star
12318 Points
2269 Posts
Re: Session Variables and Response.Redirect()
Jul 06, 2012 11:39 PM|LINK
Is your insistence on not having the PDF render to a different page by design? It seems to me that if a user clicked on a row in the GridView, you could capture that element in Session and Redirect to a third aspx page that is responsible for rendering the PDF. Then, even if you do hit back, it would go back to the page specifically concerned with generating the GridView.
gvinson89
Member
2 Points
7 Posts
Re: Session Variables and Response.Redirect()
Jul 07, 2012 12:01 AM|LINK
I figured it out, thank you both for your suggestions.
SOLUTION:
First off, I did not create this app, I am updating/fixing it, I have been thrown to the wolves so to speak. It looks like the old code that redirected the user to a new page was...
Response.Write(@"<script type='text/javascript'>window.open('ViewReport.aspx?id=" + id + "');</script>");I simply rewrote it as:
Response.Redirect("ViewReport.aspx?id=" + id, false);and it works fine now.
Thank you again.