Forum Moderators: phranque

Message Too Old, No Replies

Tough ASP/VBscript Problem

How to make the back button behave

         

craig_d

6:19 pm on Mar 9, 2005 (gmt 0)

10+ Year Member


I need some expert help to require registration on certain pdf downloads on my site (win2k, iis5), while maintaining the use of the back button which avoids the login and registration pages shown below. I'm trying to do this without javascript, if possible.

Here are the pages and partial content:

[B]Product Page...[/B]
(purpose: contains links to pdfs. some require registration, others don't)
<a href="<%="login.asp?filename=file1.pdf"%>">File1</a><br>
<a href="file2.pdf">File2</a>

[B]Login Page...[/B]
(purpose: ask for email, if previsouly registered email is found in db, open pdf...if not previously registered, provide link to registration page and remember which pdf was requested)

<p>If you haven't registered, <a href="<%="registration.asp?filename=" & request.querystring("filename"[smilestopper])%>">GO HERE</a><br><br>
If you've previsouly registered, enter your email below:</p>
<form>
...I've got working code to request email...
</form>
<% function CheckDatabase()
...I've got working VBscript and SQL code to check Oracle db for email...

HERE'S WHERE I NEED HELP:
open pdf in CURRENT window so if back button is used, the user returns to Product Page not to the Login Page.

I've tried using response.redirect(request.querystring("filename"[smilestopper])) which returns the undesired behavior explained above.

Are there other ways to do this ( non-javascript) that play well with today's pop-up blockers, i.e. XP SP2, etc?

end function %>

[B]Registration Page...[/B]
(purpose: requests user information, writes to db, opens requested pdf)
<form>
...get all user details...
</form>
<% function WriteToDB()
...I've got working VBscript and SQL code here...

HERE'S WHERE I NEED HELP:
open pdf so that if the back button is used the user returns to Product Page not to the Login or Registration Page.

The only thing I've seen is to use Javascript history.go(-2), but I can't get it to work. Are the alternatives?

end function %>

Thanks so much for your help...I'm desperate! Any good copy and paste code out there with this functionality?

lZakl

7:01 pm on Mar 9, 2005 (gmt 0)

10+ Year Member



craig_d,

I know what you are trying to do... But have you considered making two sub-directories? Ie:

/public
/private

Leave the /public folder as-is. Put all of your pdf's that you want available to everyone in there. Then through your IIS contorl panel (Or whatever your host has set up), "protect" the /private directory. Place all of the "proctected" pdf's here. You will be able to set up a list of usernames and passwords. (You can aslo do this with an Access Database and ASP.) This way, once a user is logged in, they won't have to re-login for every PDF they want to view, their session will only end when they close their browser.

Just a thought ... :0)

-- Zak

craig_d

7:17 pm on Mar 9, 2005 (gmt 0)

10+ Year Member



Thanks for that thought.

I can see how it will simplify which file are protected and which aren't, but what about the use of the back button to return to the Product Page once the pdf is loaded?

TheWhippinpost

7:30 pm on Mar 9, 2005 (gmt 0)

10+ Year Member



What about using the DOM to push the document.location.href = productpage

You'll have to check the particular DOM for your page and probably need to hard-code the desired page url.

lZakl

8:25 pm on Mar 9, 2005 (gmt 0)

10+ Year Member



When sent to the "protected" area, the Login will actually be a prompt instead of a new page, so the last page they were on, WILL be the product page.

Product page --> Password Prompt --> Protected Page

Protected Page (Back button)--> Product Page

-- Zak

Luddite

7:01 am on Mar 11, 2005 (gmt 0)

10+ Year Member



If you don't have too many concurrent users, why not set a session variable for login status?

at the begining of your registration/login pages do a response redirect if session variable is set:

<% if (session("validated") = "true") then response.redirect("products.asp") %>

& at the top of any sensitive pages:

<% if (session("validated") = "false") then response.redirect("login.asp") %>

of course you'll need to set the session variable on login..

craig_d

1:10 pm on Mar 11, 2005 (gmt 0)

10+ Year Member



Thanks for all the input.

Now it seems I'm even having trouble with the Response.Redirect in IE5x. It opens the PDF just fine in everything but this browser.