Reputation: 10329
I am trying to get started with using IIS. I created a new site on IIS Manager, mapped it to a folder on my file system and added index.html to the folder. I have set the port to 85 for this site. When I try to access http://localhost:85/index.html
, I get the following error message:
401.3 - unathorized - You do not have permission to view this directory or page because of the access control list (ACL) configuration or encryption settings for this resource on the Web server.
I gave read access to everybody on the folder and tried again. I could then access the page.
I then compared the properties of my folder with that of wwwroot. I found that wwwroot had read access on IIS_IUSRS...When I did the same on my folder and tried again, I got the above error again. I checkedthat anonymous access is enabled by default, but I still get this error.
Why does this happen? What is the correct way to resolve the problem?
Upvotes: 147
Views: 212266
Reputation: 29
you need to have URL rewrite installed in IIS for routes add a web.config
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="React Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Upvotes: 3
Reputation: 22662
TL;DR;
In most cases, granting access to the following account(s) (one|both) will be enough:
with Access Rights:
That's it!
Read on for a more detailed explanation...
Grant access to the web application folder's ACL depending what is selected in the pic above:
IUSR
(in my case) + IIS AppPool\DefaultAppPool
IIS AppPool\DefaultAppPool
onlyIIS AppPool\DefaultAppPool
account is the default AppPool account for new IIS web applications, if you have set a custom account, use the custom one.
Give the following permissions to the account(s):
Read & Execute
List folder contents
Read
Upvotes: 45
Reputation: 3496
I have struggled on this same issue for several days. It can be solved by modifying the security user access properties of the file system folder on which your site is mapped. But IIS_IUSRS is not the only account you must authorize.
OR
Upvotes: 257
Reputation: 20852
If you are working with Application Pool authentication (instead of IUSR), which you should, then this list of checks by Jean Sun is the very best I could find to deal with 401 errors in IIS:
Open IIS Manager, navigate to your website or application folder where the site is deployed to.
Run the following command:
icacls <path_to_site> /grant "IIS APPPOOL\<app_pool_name>"(CI)(OI)(M)
For example:
icacls C:\inetpub\wwwroot\mysite\ /grant "IIS APPPOOL\DEFAULTAPPPOOL":(CI)(OI)(M)
Especially steps 5. & 6. are often overlooked and rarely mentioned on the web.
Upvotes: 0
Reputation: 1
Another problem that may arise relating to receiving an unauthorized is related to the providers used in the authentication setting from IIS. In My case I was experience that problem If I set the Windows Authentication provider as "Negotiate". After I selected "NTLM" option the access was granted.
More Information on Authentication providers
Upvotes: 0
Reputation: 244
Just in case anyone else runs into this. I troubleshooted all of these steps and it turns out because I unzipped some files from a MAC, Microsoft automatically without any notification Encrypted the files. After hours of trying to set folder permissions I went in and saw the file names were green which means the files were encrypted and IIS will throw the same error even if folder permissions are correct.
Upvotes: 1
Reputation: 10088
Here is what worked for me.
To set the server anonymous to inherit from the app pool identity do the following..
Upvotes: 86
Reputation: 7496
Try this solution:
https://serverfault.com/questions/38222/iis-7-5-windows-7-http-error-401-3-unauthorized
Also check if the user running the IIS AppPool has read access to that folder/file.
Have a look at this:
http://www.iis.net/learn/manage/configuring-security/application-pool-identities
Also have a look at this:
Upvotes: 3
Reputation: 11773
Since you're dealing with static content...
On the folder that acts as the root of your website- if you right click > properties > security, does "Users" show up in the list? if not click "Add..." and type it in, be sure to click "Apply" when you're done.
Upvotes: 19