best way to redirect asp to login htm page?

R

Rich

Hello,

I need users to access a data entry asp page via a login
page. If they bookmark the data entry asp I want to
redirect them to the login page (using IIS). Here is what
I had in mind:

<%@ LANGUAGE=JScript %>
<HTML>
<HEAD>
<TITLE>Home Page</TITLE>
<script language="JavaScript">
function myFunction(s){
....
location.href='insert.htm';}
</SCRIPT>
</HEAD>
<body onLoad="myFunction('<%Response.write(Request.Form
("testfld"));%>')">
....

Isn't there some kind of authentication method for IIS, or
at least a less kludgy way of doing this than what I have
above? Just checking.

Thanks,
Rich
 
C

Curt_C [MVP]

have the login place a cookie/session variable...check for it...if it's not
there redirect
 
R

Rich

Thank you for your reply. This sounds logical. May I
request one more thing? I took a course in javascript
which used some asp examples a few years ago (didn't work
with it since then). Now I am back at it for real. We
did infact work with cookies, but I only vaguely remember
how to set/read them. Would have any sample syntax or
point me where I could see some examples? JS/vbs either
or.

Thanks again for your reply.

Rich
 
C

Curt_C [MVP]

VBScript

string = Request.Cookies("name")
Response.Cookies("name") = string
 
D

Dave Mitchell

Hey rich, does your login page submit straight to the data entry page?

If so then at the start of the data entry page you could just check that one
of the fields from your login page actually has data in it, and if it
doesn't then redirect the user back there.

so put this at thge start of your data entry page..

<%
if request.form("yourformfield")="" then

response.write "<script>alert('you must come here from the login
page.')</script>";
response.redirect "login.htm"

else
'show the data entry page


end if

%>

hoope this helps

dave
 
R

Rich

Thank you all for your responses. This really helps me
out. I actually know how to do this stuff in JSP, but I
don't want to use Tomcat because I am all hooked up with
IIS/SqlServer now. My vbscripting is weak, at best. Oh
well. I will be hanging around here a lot :).

Thanks again,
Rich
 
T

Tom Bates

Rich, how about this? A friend of mine found this (or invented it).
Put it in your global.asa file in the Session_OnStart routine.

' If someone initially tries to load any page other than the
' start page, redirect them.
' NOTE - If the redirect happens, the rest of this function
' is not executed, so be sure this is LAST!

Session("requestedPage") = Request.ServerVariables("SCRIPT_NAME")
if not (STRCOMP(Application("StartPage"), Session("requestedPage"),
vbTextCompare)=0) then
Response.Redirect Application("StartPage")
end if

Works for me. No cookies (other than ASP's own). Just set
Application("StartPage") to "login.asp" (or whatever you're using) in
your Application_OnStart routine.

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top