Tuesday, April 10, 2007

ASP.Net Development Server & Style Sheets

I'm developing my freelance web application using Visual Web Developer Express at the house. And though I do have a full fledged Web Server running IIS I could develop on, I prefer having the actual development being done on my box and then I routinely push the changes out to the website so that my partner can view a stable version of the software.

Not a big issue. It's a good paradigm.

Well it would be, except for whatever reason, the built-in development server is reporting that my style sheets have a mime type of TEXT/HTML rather than TEXT/CSS. The friendly Error Console in FireFox is reporting this:

Error: The stylesheet http://localhost:2877/Lotto/login.aspx?ReturnUrl=%2fLotto%2fcorners.css was not loaded because its MIME type, "text/html", is not "text/css".
Source File: http://localhost:2877/Lotto/login.aspx?ReturnUrl=%2fLotto%2fdefault.aspx
Line: 0
And while once you get logged into the system, it's not a problem - prior to that, when TEXT/HTML files are restricted, it means that none of my pretty styles are showing up for the login screen. And it's not just the VWDE that I'm using at home - it's also my Visual Studio Professional at work. At lunch the other day, I tried it and came up with the same results of CSS being misreported as the wrong MIME type.

And it gets better. Even external JavaScript files are doing something flaky:

Error: syntax error
Source File: http://localhost:2877/Lotto/includes/prototype.js
Line: 3
Source Code:
Google, Asp.Net, MSDN and Google Groups are, of course, utterly unhelpful with this particular issue.

Of course, while I was building my little blog entry here, I realized what was truly happening.

I had disabled the ability for things to be retrieved from the web server without authentication. Which meant, any request prior to the user being logged into the system would be met with the login prompt. Which meant that I was trying to load in my LOGIN page in my style sheet & script tags.

It's at times like these that I feel utterly brilliant.

Anyways, moving my stylesheets to my INCLUDES folder and then adding in the following to my web.config solved my problem.

<location path="Includes">
<allow users="*">

Now, if only I had the time I spent trying to figure this out back. Though I guess, that's what I get for not paying close enough attention to the message that Error Console is reporting to me.


Anonymous said...

Thanks. Seriously. Feel like a complete 'tard after reading this seeing that this was a self-inflicted wound.

Stephen Wrighton said...

No, don't feel bad. I wrote it like it was this simple and easy thing to solve, but in actuality I spent around a week banging my head against the wall before I figured it out.

Blog Widget by LinkWithin