I have an ASP.NET web-site with authentication using ActiveDirectory.
Now, when an authenticated user opens a page - he is automatically authenticated. I have faced a problem - when a non-authenticated user (for example, a Mozilla Firefox user with not defined network.automatic-ntlm-auth.trusted-uris
property) opens a page, IIS sends 401 response and prompts for a login \ password.
What I want is not to prompt him for a login \ password - just show a custom error page. It sounds pretty simple - authenticated users get the requested page, non-authenticated are redirected to a custom error page. It would work fine for FormsAuthentication.
However, I have tried so many ways by now. Any Web.config redirects are not working. Even if I clear a Response
and put there a redirect - I will get a loop because this custom page (*e.g., /Error/AccessDenied
) also requires authentication. Marking a controller as AllowAnonymous
does nothing.
However, if I enable Anonymous authentication in IIS Manager, real authenticated domain users are not being authorized when they open a web-site.
How can I solve this problem?