Reputation: 3625
The webpage that I am creating can't access the CSS file.
Take a look at my webconfig:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="MySql.Data, Version=6.2.5.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
</system.web>
<location path="css">
<system.web>
<authentication mode="Forms">
<forms name=".ASPXFORMSDEMO" loginUrl="Login.aspx" protection="All" path="/" timeout="60"/>
</authentication>
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>
</system.web>
</location>
</configuration>
I found some answer here:
Authorization Issue - anonymous users can't access .jpeg or .css
But when I tried to put
<location path="css">
on top of 'system.web' it didn't work. Please help me fix this. Thanks for all your help guys!
Upvotes: 0
Views: 4087
Reputation: 17614
as you are using <authentication mode="Forms">
and protection="All"
so you can't access any file other than loginUrl
without login.
If you want to access any file or folder without login you should tell this in you web.config file as follows
<location path="file_name">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
Or if you want any folder to be accessible without login then you should be using this as follow
<location path="folder_name">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
The tag <allow users="*" />
works for you. It allows the user to access that path without login.
Here are some good links
http://msdn.microsoft.com/en-us/library/b6x6shw7%28v=vs.71%29.aspx
http://msdn.microsoft.com/en-us/library/ms178692%28v=vs.100%29.aspx
Upvotes: 2
Reputation: 17724
The location tag has to be a direct child of configuration
Put this under your existing <system.web>
<configuration>
<system.web>
...
</system.web>
<location path="css">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
</configuration>
Upvotes: 4