How do I fix 401 unauthorized error IIS?

In short, let’s remember the following things about HTTP status codes in Web API projects:

  1. Always return the appropriate status code, however you define “appropriate”.
  2. Use the shortcut methods (e.g. Ok() , NotFound() , etc.) …
  3. An action that returns void will send status code 204 No Content.
  4. Open IIS and select site that is causing 401.
  5. Select Authentication property in IIS Header.
  6. Select Anonymous Authentication.
  7. Right click on it, select Edit and choose Application pool identity.
  8. Restart site and it should work.

For More Information Please Refer: https://stackoverflow.com/questions/11162430/401-unauthorized-on-a-directory