Article ID: 159977 - Last Review: May 2, 2006 - Revision: 4.0 How To Stop Users from Displaying a Frame Outside Its Frameset in Active Server PagesThis article was previously published under Q159977 On This PageSUMMARY
Microsoft Active Server Pages can be used to prevent Web browsers from
calling a document that is supposed to be displayed as a part of a
frameset. Stop Users by Redirecting RequestsWeb documents that are part of a frameset are often not designed for individual display. To prevent users from viewing these documents outside of their appropriate frameset, you can use the Internet Information Server (IIS) Active Server Pages (ASP) "Response.Redirect" and "Request.ServerVariables" methods to redirect Hypertext Transfer Protocol (HTTP) requests to the frameset page.Assuming the following document structure:
Frameset Page (mainfrm.htm)
Frame 1 (frame1.asp)
Frame 2 (frame2.asp)
159402
(http://support.microsoft.com/kb/159402/EN-US/
)
How To Use Response.Redirect in a Server Script
In this code, the first part of the If statement
(Request.ServerVariables("HTTP_REFERER")= "") checks to see if you
connected to the page directly by typing the URL into the browser. If you
connect to the page this way, a "referer" is not found in the header and
the browser is redirected to the main page that contains the frameset.
The second half of the If statement is (Left(Request.ServerVariables("HTTP_REFERER"),42) <> "http://www.myserver.com/AppDir/mainfrm.htm"). This line checks to see that you connected to frame1.asp from the frameset page(mainfrm.htm). If not, the browser is redirected to the main page containing the frameset. The line: redirects the browser to the following page:
http://www.myserver.com/AppDir/mainfrm.htm.
You can use the following code to demonstrate this. Save each in a separate
file and use the names indicated below. Also, you need to make the
following modifications to the code in the frame1.asp file:
File: Mainfrm.htmFile: Frame1.aspFile: Frame2.aspREFERENCES
For the latest Knowledge Base articles and other support information on
Visual InterDev and Active Server Pages, see the following page on the
Microsoft Technical Support site:
http://support.microsoft.com/search/default.aspx?qu=vinterdev
(http://support.microsoft.com/search/default.aspx?qu=vinterdev)
| Article Translations
|


Back to the top
