Failed to load resource: the server responded with a status of 401 (Unauthorized) /App/AngularJS/angular.min.js

105,585

Solution 1

When servers respond with access denied message (401 Unauthorized access), it means that the anonymous IIS user account is unable to access the resources because of permission issues.

By default, IUSR account is used for anonymous user.

All you need to do is:

IIS ->
Authentication --> Set Anonymous Authentication to Application Pool Identity.

Problem solved :)

Solution 2

Also I have set the read/write/modify access for "IUSR" & "IIS_IUSR" users of whole project. properties image

this was enough for me to get around the same issue.

PS. sorry for using your image, just want to emphasize the step you mentioned that worked for me.

Solution 3

Well,

It's strange but It worked. The solution was to set the default user for "Connect as" in IIS. See the image given below.

enter image description here

I specified the administrator user & this started to work in IIS. I think this is some kind of requirement with AngularJS to work on IIS.

Thanks for replies.

Solution 4

Assuming that you are using form authentication and you are trying to get it before login. You can use the following in your web.config file inside <configuration>.

<location path="AngularJS">
 <system.web>
  <authorization>
    <allow users="*" />
  </authorization>
</system.web>
</location>

It will make you files inside AngularJS folder available without login

Share:
105,585

Related videos on Youtube

user1400290
Author by

user1400290

Updated on July 09, 2022

Comments

  • user1400290
    user1400290 almost 2 years

    I am having the following error:

    Failed to load resource: the server responded with a status of 401 (Unauthorized) http://localhost/App/AngularJS/angular.min.js
    

    The project works fine on localhost. But when I run it on IIS (7.5) I get the above exception.

    [Image] enter image description here

    My project is .net 4.5 project (Web.API 2.2), I am using AngularJS for UI in this project.

    I have tried running "aspnet_regiis - i" as somewhere this was accepted as solution. But it didn't work in my case. I don't know is there any thing required to execute [AngularJS].js files on IIS for Web.API project?

    EDIT:

    I have made following changes to web.config file:

    <location path="AngularJS">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
    </location>  
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
      <compilation debug="true" targetFramework="4.5" />
     <httpRuntime targetFramework="4.5" />
    </system.web>
    

    Also I have set the read/write/modify access for "IUSR" & "IIS_ISURS" users of whole project. enter image description here

    But still I get the same exception on IIS. But same running fine with VS2013.

    Error: enter image description here

    • Chandermani
      Chandermani over 9 years
      401 is a authnorization exception. You should be logged in and the user should have access to folder app/angularjs or anonymous access should be enabled on the above folder.
    • Zafer Sernikli
      Zafer Sernikli over 9 years
      Make sure that the folder in which angularjs file is kept has public access allowed. Just go to that folder, go to properties, security and see the permissions.
  • user1400290
    user1400290 over 9 years
    I have tried your suggestion but it didn't work for me, see my edit.
  • Kyle Vassella
    Kyle Vassella almost 6 years
    I'm using IIS express - would my steps be any different? I'm guessing your steps IIS ->Authentication --> Set Anonymous Authentication to Application Pool Identity is done in the IIS configuration manager, but I'm unsure that I have a tool like that for IIS Express