Sometime, we get this error message after publishing the solution in IIS. This error is quite common.

Exact 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.

This particular error happens mostly because of authentication setting in IIS.

Solution:

Open the IIS.

Select the site you are facing issue.

Select Authentication Setting as shown

Based on your application requirement, you can update authentication options

In my case, the application needs to set windows authentication, therefore, I set it enabled and Anonymous Authentication Disabled.

Regards