Attention: We are retiring the ASP.NET Community Blogs. Learn more >

How to use the ASP Page Framework

I had a couple of e-mail requests asking me how to use the Classic ASP Page Framework which I discussed in my last blog entry so I thought that I'd make a couple of notes in an attempt to try an clear things up a bit.  First, the code for the Framework can be found here:

    http://flws.com.au/AuthenticateModel.html

To use it you include the code in each page as a server-side include and configure the security.

To configure security you just create a comma-delimited string of pages which should be secured like so:

   Application( "MIU_PAGES_TO_SECURE" ) = "Foo.asp, Bar.asp, etc"

 

Whenever a user browses to one of those pages they are automagically taken to the login page (if they are not already authenticated). You set the login page via an Application variable too:

    Application( "MIU_LOGIN_PATH" ) = "Login.asp"

 

If a user successfully logs in they are automagically redirected back to the page that they came from:

    ElseIf Me.Page.IsAuthenticationPage And Not Me.User.IsAuthenticated() Then
        FormsAuthentication.RedirectUrl = Request.QueryString( "RedirectUrl" )
    End If

 

When a user logs out you can specify which page they should be re-directed to:

    Application( "MIU_DEFAULT_ENTRY_PATH" ) = "Default.asp"

 

The framework also has some for RoleBased authentication which you can query off of the current user at anytime like so:

    If User.IsInRole( "admin" ) Then
        ' do something based on the admin role
    End If

 

No Comments