Problems with Forms Authentication and ASP.NET Themes

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:

To fix this, I allow unauthenticated access to the resources, which was straight-forward. I added the following to the web.config file:

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:

Once I saw this, it all fell into place!

Please follow and like us:
  • Thanks. This resolved my issue with unauthenticated users accessing style sheets.

  • Anonymous

    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

  • Anonymous

    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

  • Anonymous

    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!

  • Anonymous

    Thank you very muuuuuuuuuch

  • Anonymous

    Thanks. This resolved my issue with unauthenticated users accessing style sheets and images.

  • Anonymous

    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.

  • Anonymous

    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:

  • Thank you.. CSS applied successfully but images are not displaying..