"401 Unauthorized" on a directory

asp.netasp.net MvcIisIis 7

asp.net Problem Overview


I assume this is an IIS error, as this doesn't happen if I run the project on my local machine.

I have my stylesheets at ~/Content/css

Any files in that directory won't load on the page, and when I navigate to them directly, I get a server error:

>401 - Unauthorized: Access is denied due to invalid credentials. > >You do not have permission to view this directory or page using the credentials that you supplied.

This only happens with that directory, I have no problem accessing any other files. Is there something I need to do in IIS7 to stop this?

asp.net Solutions


Solution 1 - asp.net

  1. Open IIS and select site that is causing 401
  2. Select Authentication property in IIS Header
  3. Select Anonymous Authentication
  4. Right click on it, select Edit and choose Application pool identity
  5. Restart site and it should work

Solution 2 - asp.net

It is likely that you do not have the IUSR_computername permission on that folder. I've just had a quick scan and it looks like you will find the information you need here.

If that isn't the case, are you prompted for your username and password by the browser? If so it may be that IIS is configured to use Integrated authentication only, as described here.

Solution 3 - asp.net

  • Open IIS

  • select site where you are facing the problem

  • Select Below

enter image description here

- Right click on Anonymous Authentication and click on edit and follow below

enter image description here

Solution 4 - asp.net

You do not have permision to view this directory or page using the credentials that you supplied.

This happened despite the fact the user is already authenticated via Active Directory.

There can be many causes to Access Denied error, but if you think you’ve already configured everything correctly from your web application, there might be a little detail that’s forgotten. Make sure you give the proper permission to Authenticated Users to access your web application directory.

Here are the steps I took to solve this issue.

  1. Right-click on the directory where the web application is stored and select Properties and click on Security tab.

  2. Click on Click on Edit…, then Add… button. Type in Authenticated Users in the Enter the object names to select., then Add button. Type in Authenticated Users in the Enter the object names to select.

  3. Click OK and you should see Authenticated Users as one of the user names. Give proper permissions on the Permissions for Authenticated Users box on the lower end if they’re not checked already.

  4. Click OK twice to close the dialog box. It should take effect immediately, but if you want to be sure, you can restart IIS for your web application.

Refresh your browser and it should display the web page now.

Hope this helps!

Solution 5 - asp.net

You need to check the folder permissions on your server and check that the account that you are using to run your application has access to that folder.

Solution 6 - asp.net

For me the Anonymous User access was fine at the server level, but varied at just one of my "virtual" folders.

Took me quite a bit of foundering about and then some help from a colleague to learn that IIS has "authentication" settings at the virtual folder level too - hopefully this helps someone else with my predicament.

Solution 7 - asp.net

In our case it was Windows-integrated authentication specified in the app's web.config

BUT the windows-auth module was not installed on the IIS machine at all.

Just adding another possible reason.

Solution 8 - asp.net

Another simple fix I found was to delete the local IIS site (from within IIS Manager) and then re-create the virtual directory from the "Properties" of your web project in Visual Studio.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionStevenView Question on Stackoverflow
Solution 1 - asp.netjasenkohView Answer on Stackoverflow
Solution 2 - asp.netm.edmondsonView Answer on Stackoverflow
Solution 3 - asp.netSiddharthaView Answer on Stackoverflow
Solution 4 - asp.netKent AguilarView Answer on Stackoverflow
Solution 5 - asp.netGaz WinterView Answer on Stackoverflow
Solution 6 - asp.netuser6096790View Answer on Stackoverflow
Solution 7 - asp.netAlex from JitbitView Answer on Stackoverflow
Solution 8 - asp.netKWondraView Answer on Stackoverflow