Sometimes we receive this error message after publishing the solution in IIS. This mistake is very common.


Exact Error
Error message 401.2: Unauthorized The login failed due to server configuration. Check that you have authorization to browse this directory or page using the credentials you provided and the authentication methods enabled on the Web server. For further assistance, contact the web server administrator.

This problem is mostly caused by IIS's authentication settings.

Solution
Launch the IIS.

Choose the site where you are experiencing the problem.
Select Authentication. Setting as indicated.


Authentication choices can be updated based on your application's requirements.

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