<Location Path=""> not working in web.config (in full IIS)
I am trying to add allow all to my content anonymous access in my content directory for my css and js files bit it is not working.
This works in IIS Express but not the full IIS.
A section from my web.config is below.
<!-- Show default CSS and image-->
<location path="Content">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<system.web>
<httpRuntime requestValidationMode="2.0" />
<compilation debug="true"
targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyTok开发者_JAVA技巧en=31BF3856AD364E35" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Home/SignIn"
path="/" />
</authentication>
.....
*
means only authenticated users. Use a ?
to denote anonymous users. Source: ASP.NET Authorization.
Besides enabling Anonymous Authentication for the web site, I had to go a step further and Edit Anonymous Authentication (by right clicking) and change it from a Specific User to Application pool identity.
try doing the following:
- First ensure you use question mark symbol
?
which denotes anonymous user access. Also, to be able to interpret the?
option you should enable the valueIIS site > Authentication > Anonymous Authentication > Enabled
- Next you might need to enter the
Edit...
screen and set the user to an explicit one (and AD user is prefered in web farm scenario) or the current application pool identity.
The location XML should be:
<location path="Content">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
Notice the ?
value which differs from *
which you added in the question.
精彩评论