Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I implement the protection of the pages ( mvc app), so when I hit the home page or any other pages within the application I get a login dialog popup in the browser

I'm looking for something similar to what Apache .htaccess and .htpasswd is doing.

I have IIS 7.5/Windows Server 2008 R2 Web edition.

share|improve this question

migrated from May 21 '11 at 21:31

This question came from our site for professional and enthusiast programmers.

First of all you need to enable Basic Authentication. You can find this setting in the Authentication feature for the site in IIS Manager:

enter image description here

Double click on the icon then right click on Basic Authentication and select Enable:

enter image description here

You can also configure this directly in your web.config file (your application doesn't even have to be an ASP.NET application):

<?xml version="1.0" encoding="UTF-8"?>
                <basicAuthentication enabled="true" />

This will only work in the web.config provided that this feature has been delegated as Read/Write.

Out of the box you would need to create a separate Windows 2008 account for each login.

If you wanted to use a custom store (SQL Server, Membership Service) then you'd need to write your own Basic Authentication module:

Developing a Module Using .NET

share|improve this answer

In the IIS Manager in Sites->Yoursite->Authentication you can disable "Anonymous Authentication" and enable "Basic Authentication" or any HTTP 401 Challenge that's appropriate for your website.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.