It's sometimes the strangest (and seemingly irrelevant) combinations of technology that give you the most problems. For a good few hours I've been wondering why my web site, which uses Forms Authentication and Themes, was not displaying any formatting or images.
It turns out that the URLs specified in the authentication section in web.config are used for ALL resources. So, in my case, the page was trying to load a .css file but ASP.NET was redirecting the request to default.aspx, which of course, is not a style-sheet and has a different MIME type. Here's the section of my web.config file:
<authentication mode="Forms"> <forms loginUrl="Default.aspx" defaultUrl="Default.aspx" protection="All" timeout="30" path="/" requireSSL="false" slidingExpiration="true" cookieless="UseDeviceProfile" domain="" enableCrossAppRedirects="false"/> </authentication>
To fix this, I allow unauthenticated access to the resources, which was straight-forward. I added the following to the web.config file:
<location path="App_Themes"> <system.web> <authorization> <allow users="*"/> </authorization> </system.web> </location>
The tricky part in finding this was that the page's HTML looked fine, there were no errors, and saving the resulting HTML to a file and viewing it produced the right results.
Firefox's JavaScript Console proved incredibly helpful in finding the problem:
11 comments:
Thanks. This resolved my issue with unauthenticated users accessing style sheets.
Thank you very much. This fixed a problem that initially didn't make any sence to me.
Great. I was thinking in that but i did not realize how i have to put it on the web.config
Steve this was a fantastic find I just started having this problem and you have saved a lot of time trying to find the answer. One word GENIUS
thanks a lot, i had the same problem..near to get weird..
Thank you so much... That's the kind of problem that makes me insane... Thanks a lot again from Argentina!
Thank you very muuuuuuuuuch
Thanks. This resolved my issue with unauthenticated users accessing style sheets and images.
Thanks. It took me a whole day to find your Blog. The strange thing is that the skin files keep working. If you rename your Blog to "Problem with css - stylesheet and ASP themes" I think you'll get more visitors.
Thanks for the info, but it didn't solve my problem. Just in case anybody else is out there pulling their hair out, here's another possible cause for this situation:
http://gurustop.net/blog/2009/10/12/funny-problem-windows-7-iis-7-5-images-css-not-showing/comment-page-1/#comment-505
Thank you.. CSS applied successfully but images are not displaying..
Post a Comment