Click here to Skip to main content
15,868,141 members
Articles / Web Development / IIS

Protecting pages with include files

Rate me:
Please Sign up or sign in to vote.
3.86/5 (4 votes)
14 Sep 2000CPOL 137.3K   1.2K   35   18
An article on how to easily password protect a site using include files

Introduction

In this article I will show you how to authenticate users so as to protect pages from being seen without permission. It uses a set of ASP files that will be included to each page that needs protection.

In the example the authetication occurs with a couple of StrComp comparsions, but in real world it should be done using a table or a COM component.

These are the necessary asp files with a explanation of its use:

Login.asp This file ask for the userID and password
LoginCheck.aspThis file checks if the userID and password are OK. If so it redirects to the correct page, otherwise it redirects to the Access Denied page
AcessDenied.asp This is the file with the Access Denied message, nothing more
Pages.aspTo be able to redirect to the right page after the login I gave each page a unique identifier. So this file has the list of pages and it's identifier. The URL is retrieved from the function GetURLFromNumber
Protector.aspThis file must be included in each page that needs protection. Before its inclusion an identifier called nURLID must be declared with the value of the identifier for this page (see Pages.asp).

To see it working click here

More information about include files can be found typing "#include" on the Index page of MSDN.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect VisionOne AG
Switzerland Switzerland
XicoLoko is a brazilian developer based in Switzerland.

Comments and Discussions

 
Questionwhat should i do with my retrieve data from database Pin
vannak15-Jun-03 13:35
vannak15-Jun-03 13:35 
GeneralMissing pages.asp Pin
8-Jul-02 8:42
suss8-Jul-02 8:42 
GeneralRe: Missing pages.asp Pin
Peter, The Pumpkin Eater19-Apr-03 1:46
Peter, The Pumpkin Eater19-Apr-03 1:46 
GeneralMISSING PAGES.ASP Pin
3-Jul-02 20:38
suss3-Jul-02 20:38 
GeneralPages.asp missing Pin
7-Jun-02 9:42
suss7-Jun-02 9:42 
GeneralPages.asp missing Pin
4-Oct-01 12:24
suss4-Oct-01 12:24 
Generallost navigation Pin
25-Jan-01 5:41
suss25-Jan-01 5:41 
GeneralTwo Comments Pin
James Curran23-Aug-00 7:59
James Curran23-Aug-00 7:59 
GeneralRe: Two Comments Pin
xicoloko23-Aug-00 10:31
xicoloko23-Aug-00 10:31 
GeneralRe: Two Comments Pin
James Curran23-Aug-00 17:52
James Curran23-Aug-00 17:52 
GeneralRe: Two Comments Pin
Tom Wellige23-Aug-00 22:25
Tom Wellige23-Aug-00 22:25 
GeneralRe: Two Comments Pin
James Curran24-Aug-00 10:56
James Curran24-Aug-00 10:56 
GeneralRe: Two Comments Pin
Uwe Keim24-Aug-00 19:40
sitebuilderUwe Keim24-Aug-00 19:40 
GeneralRe: Two Comments Pin
Tom Wellige24-Aug-00 21:01
Tom Wellige24-Aug-00 21:01 
GeneralRe: Two Comments Pin
Claude Vedovini28-Aug-00 7:18
Claude Vedovini28-Aug-00 7:18 
GeneralRe: Two Comments Pin
Tom Wellige29-Aug-00 10:19
Tom Wellige29-Aug-00 10:19 
GeneralRe: Two Comments Pin
drkar18-Sep-00 7:25
drkar18-Sep-00 7:25 
GeneralRe: Two Comments Pin
shabbir karim25-Dec-02 23:59
sussshabbir karim25-Dec-02 23:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.