Click here to Skip to main content
Click here to Skip to main content

A single file login page for

By , 19 Aug 2012
Rate this:
Please Sign up or sign in to vote.

Sometimes you might feel the need to simply protect a public directory on your webserver. Using IIS gives you several options to achieve this, but today we will discuss how to enable a simple login page that requires only one file and a few entries in web.config. 

First of all I used the login page created by Alen Grakalic he created a great CSS3 Login page with validation, and everything in a single file. Perfect that's just what we needed to create a simple drop in login page for iis using

The final result will look something like this:


To install it just copy the contents of the zip attached to this post to your iis webserver. Make sure that your application pool is configured to run under 4.0.

To edit the user accounts open the web.config file and find the credentials section, where you can edit the user accounts that are allowed to log in. Pay special atention to this section in web.config:

    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true"></modules>

This section makes sure that if you have files in the public directory that are not handled by (e.g. html/text/image files) are protected as well.

This section is also quite important as it denies anonymous users access to your content:

   <deny users="?" />

With the proper configuration this solution is secure, and it's not easy to circumvent the login mechanism. The login logic is provided by, and has been thoroughly tested by Microsoft and developers all around the world. Of course this is just an example and I'm in not responsible for the security of your content, always do some tests!

For a demo go to:

You can login with the accounts:

username: user1 
password: secret

username: admin
password: secret#23 

Download On the post page



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

About the Author

Software Developer Dexchange Outsourcing
Netherlands Netherlands
No Biography provided
Follow on   Twitter

Comments and Discussions

GeneralMy vote of 5 PinmemberChristopher Sommers23-Aug-12 14:16 
QuestionAttachments Pinmembertlhogi.mmusi9-Nov-11 1:38 
AnswerRe: Attachments Pinmemberwullinkm9-Nov-11 1:41 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 20 Aug 2012
Article Copyright 2011 by wullinkm
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid