0

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!

2 Answers 2

4

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>
Sign up to request clarification or add additional context in comments.

2 Comments

Please check my edit, I edit my webconfig but I got this error: 'It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.'
Do not copy all your elements. You only need to set the authorization. Authentication remains part of your main <system.web>. You will also need an appropriate <authorization> tag there to block unauthenticated users.
2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.