Asp.net-mvc – Trying to set up an application in IIS gives me error: Error message 401.2.: Unauthorized: Logon failed due to server configuration

asp.netasp.net-mvciis-7

I created a web application by going to IIS right-clicking on Default Web Site and selecting Add Application. Then I give the Alias name, select DefaultAppPool and point it to Physical path.

When I try to browse to http://localhost/mywebapp I get 'Access is denied' with following details:

Error message 401.2.: Unauthorized: Logon failed due to server
configuration. Verify that you have permission to view this directory
or page based on the credentials you supplied and the authentication
methods enabled on the Web server. Contact the Web server's
administrator for additional assistance.

  • Anonymous Authentication is enabled on the IIS Website.
  • The web application is ASP.NET MVC5 application.
  • The web application is running under its default identity: ApplicationPoolIdentity

Here are the settings for DefaultAppPool

enter image description here

Best Answer

Make sure your application is not on a network share or in the windows user (magic) directory. (It can be in the Visual Studio default magic user directory if you follow my instructions below)

If you're on Win7, create a new MVC 3 application, ^F5 to run. Then in solution explorer, right click the project and select properties. In the left pane, select the Web tab. The default is Cassini ( Use Visual Studio Development Server). Select the next radio, Use Local IIS Web server. Now ^F5 and it will launch your app from IIS. You can also find your application in IIS manager and in the right pane, select browse 80. Now that it's working, compare the differences in your two application.

Your approach should also work. You might try creating a new MVC application and use your approach to test on IIS. The most common mistake is creating a vDir, not an application

The error message is pretty good. To set ACLS on the application pool identity, follow the instructions under Securing Resources at http://learn.iis.net/page.aspx/624/application-pool-identities/

Also see Understanding Built-In User and Group Accounts in IIS 7

IF the new MVC app should fail, repeat, but create a Web Forms app.

Related Topic