[SOLVED] IIS Forms Authentication throws a 401 Error


We are currently setting up forms authentication for our web app.
The plan is for users to be redirected to a login page on our main system when they want to access files.

IIS Settings

Setting the IIS "Authentication" to anonymous gives access to the files.

BUT when we change the authentication to "Forms" and disable everything else we are met with a constant 401 error when trying to access the file.

401 Error

enter image description here

There is no redirect. It just throws this error.
The Web config has been changes to allow "?" (anonymous) and allow="*".
This does not change the 401 error.

When anonymous access is enabled (alongside forms auth) there is no redirect. The users have direct access to the files. (As if forms authentication is not even enabled?

Web Config

enter image description here


Please note that I also had to add machine keys to my web.config and also had to add the domain name in the authentication tags (also in the web config). After also adding a cookie.domain in my C# side the authorisation is finally working between domains.
–This has to be done when working with 2 subdomains. Eg: 1.website.com and 2.website.com.

Answered By – Michael Hanekom

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *