Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 07, 2012 12:01 AM by gvinson89
Jul 06, 2012 09:57 PM|LINK
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";
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";
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")
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)
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.
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.
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.
Jul 07, 2012 12:01 AM|LINK
I figured it out, thank you both for your suggestions.
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...
I simply rewrote it as:
Response.Redirect("ViewReport.aspx?id=" + id, false);
and it works fine now.
Thank you again.