ASP 101 - Active Server Pages 101 - Web03
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash




ASP.NET version of "Login & Password (Database-Driven)"


When I went to write an ASP.NET version of our Classic ASP Auto-Navigation Database-Driven Login Sample, I realized that I hadn't yet published a plain database-driven login and password sample for ASP.NET. So... in an effort to keep the horse in front of the cart, here it is (I mean the sample... not a horse or a cart).

There is one slight issue with the running version. Our samples folder is set up as it's own application and I'm having a hard time finding out how to (or if you even can) configure two different forms authentication login pages within one application. So... if you try and access the protected page without being logged in, you'll get sent to the login page for our plain vanilla (not database-driven) login and password sample. It's a little weird, but it shouldn't affect anyone unless you try and implement both scripts in the same folder, which I can't see why anyone but us would even try.

The zip file contains the login form (login_db.aspx), a sample protected page (login_db-protected.aspx), the config file that sets up the authentication for the application (web.config), and the database containing the login and password information (login.mdb). The sample database is an Access database which you'll need to secure so that users can't download the whole database file if you are going to continue to use Access. I only used Access so that I could easily distribute the sample database, but the concept is the same regardless of the database platform you use.

Warning: If you are going to implement this for an existing application, do not overwrite your existing web.config file or you will lose whatever settings you may have in it. Simply copy the applicable parts from our sample web.config into your application's existing web.config file.

Here's a zip file of the code (12.6 KB).

Play with the running version.

View the live source code.


Database-Driven Auto-Navigation Version

This version is based on the above database driven login and password system, but adds the capability to have users automatically directed to a user-specific login page upon authentication.

For a full description of what the sample does, you might want to read the write-up of the classic ASP version: Database-Connected Auto-Navigation Login & Password Sample

The way it is currently implemented, each destination page is secured so that only the specified authorized users can access it (as opposed to it being accessible by any authenticated user). Implementing a system where all the destination pages are accessible by any authenticated user (and the user is simply directed to their particular page by default -- even though they really have permission to access any of them) is somewhat simpler since it wouldn't require any changes to web.config for each new user. That being said, it seemed better to illustrate this method (more complex and tighter security) and let you choose to make it less secure if you want, as opposed to doing things the other way around.

You can download a zip file containing the script and sample database from here: login_db_nav_aspx.zip (11 KB)


Back to the "Classic ASP Login" sample


Samples

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES