Error message 401.2.: Unauthorized: Logon failed due to server configuration.

When you deploy MVC application, you might get the below error:

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.

Solution:

  • First check the project property windows, whether the windows authentication is enabled.

  • Goto IIS, select the respective website, click diectory browsing under IIS on right side -> enable it.

  • Goto IIS, select the respective website, click Authentication under IIS on right side -> enable windows authentication