Solved

Response.Redirect w/targets

Posted on 2002-05-11
10
1,564 Views
Last Modified: 2007-11-27
I have a web site that allows users to log in.  Every page accessed checks to ensure their session is still valid.  If it isn't it's supposed to redirect them back to the login page.  Problem is, the site starts out as a single page, then, upon login Redirects people to a frameset page.  So if any one of the frameset pages redirects the user, the login window would appear in the frameset.

How can I redirect to "_parent"?
0
Comment
Question by:Lee W, MVP
  • 5
  • 4
10 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 7004119
Redirect to _parent? This can be solved using JavaScript.

<script language="JavaScript">
    window.open "your_page.asp";
</script>

hongjun
0
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 7004128
I don't know JavaScript much at all.  Please provide the code I would use.

Figure, as of now, every page uses an "include" file that says:

<%
IF SESSION("ACTIVE") <> "TRUE" THEN
   RESPONSE.REDIRECT("login.asp")
END IF
%>
0
 
LVL 33

Expert Comment

by:hongjun
ID: 7004133
Below example code will open login.asp with target="_parent".


<%
IF SESSION("ACTIVE") <> "TRUE" THEN
%>
<script language="JavaScript">
   window.open "your_page.asp";
</script>
<%
END IF
%>


hongjun
0
 
LVL 33

Accepted Solution

by:
hongjun earned 70 total points
ID: 7004136
Should be this

<%
IF SESSION("ACTIVE") <> "TRUE" THEN
%>
<script language="JavaScript">
  window.open "login.asp";
</script>
<%
END IF
%>


hongjun
0
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 7004714
That opens a new window.  I don't want a new window, I want the PARENT of the frameset to be the window that gets the login window.  Basically, I want to cancel the frameset and go back to the login page.  
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 95

Author Comment

by:Lee W, MVP
ID: 7004729
The only reason I'm accepting this as an answer is because you said to use javascript.

The apparently correct way to do it is:

<%
IF SESSION("ACTIVE") <> "TRUE" THEN
%>
     if (document.images)
          location.replace("http://www.somesite.com/index.asp");
     else
          location.href = "index.asp";
     //--></SCRIPT>
<%
END IF
%>

I found the above sample on www.irt.org - They seem to have an extensive FAQ about javascript and other web related stuff...
0
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 7004731
I missed a line - to clarify for anyone else who wants the answer:


<%
IF SESSION("ACTIVE") <> "TRUE" THEN
%>
<SCRIPT LANGUAGE="JavaScript">
    <!--
    if (document.images)
         location.replace("http://www.somesite.com/index.asp");
    else
         location.href = "index.asp";
    //-->
</SCRIPT>
<%
END IF
%>
0
 
LVL 33

Expert Comment

by:hongjun
ID: 7005640
Why a C grade here? You request for code to do target="_parent" and I gave you. Perhaps you should rephrase your question. This is misleading.

hongjun
0
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 7006345
Because it didn't work... I tried your code and it opened a new window - an effective "target=_blank", it did not load the page in the _parent window.

I'll clarify. I have one browser window.   I open frame based web page.  20 minutes later, the session expires.  Currently, my code (which I realized doesn't work) redirects the current frame to the login page.  Essentially the same as the ASP code I first posted.  Your code opens a new browser window, leaving the old one there - NOT what I wanted.  I want to stay with the 1 browser window and basically load a non-frames page to tell the user to re-login.  If you can provide a better answer, I'll see if I can't get this answer grade changed.
0
 

Expert Comment

by:daveabad
ID: 7531555
This is the technique I use....

<%
if session("seclevel") < 2 then
  session.abandon
  response.write "<html><body onload='top.location='/'></body></html>"
else
  'happy auth'ed user stuffs
end if
%>

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now