Solved

Response.Redirect w/targets

Posted on 2002-05-11
10
1,554 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 95

Author Comment

by:Lee W, MVP
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 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

6 Experts available now in Live!

Get 1:1 Help Now