tags:

views:

948

answers:

3

When developing (works fine live) the pages for our website don't pick up the correct CSS until the user has authenticated (logged on).

So the Logon and Logoff forms look bad, but once inside the site, the CSS works again.

I'm guessing it's some kind of authentication issue? Haven't really looked into it too much because it's only when working on dev so not a huge issue, but would be nice to know how to fix it.

+7  A: 

Check and make sure that the CSS file itself is not in an area that you are securing. You can manually exclude the file via the web.config if needed.

RobZ
Manually exclude by adding the following in the <Configuration> section: <location path="css"> <system.web> <authorization> <allow users="*"></allow> </authorization> </system.web> </location>
KiwiBastard
This is good. Then how is it working in your production evironment? You should have the same problem there unless this section is missing in your dev web.config
Gulzar
I have this exact same issue - login page is unstyled on dev and fine on production. web.config is exactly the same except for connection strings and debug settings. This solution didn't solve the problem for me.
Adam Pope
Correction: Had a dumb moment, it does work if you specify the whole path e.g. path="App_Themes/Theme" or path="App_Themes/Theme/file.css"
Adam Pope
+1  A: 

Can you try using a tool like Fiddler or HttpWatch and check if a request actually goes for the .css file from the login page. Verify the return codes are 200. Could be because of relative path issue in your dev box.

Gulzar
+3  A: 

To allow an unauthenticated user to see your .css files (or any other file/directory) you can add a location element to your web.config file pointing to the .css file.

<configuration>
   <system.web>
      // system.web configuration settings.
   </system.web>
   <location path="App_Themes/Default/YourFile.css">
      <system.web>
         <authorization>
            <allow users="*"/>
         </authorization>
      </system.web>
   </location>
</configuration>

Jason