22

i am having a login page when executed the page is stripped out of css.

I found out this message from from chrome debugger. I am using asp.net 2008.

Any ideas?

<head id="Head1" runat="server"> 
<title>CalibPro</title> 
<link href="css/Login.css" rel="stylesheet" type="text/css" /> 
<link href="css/Common.css" rel="stylesheet" type="text/css" /> 
</head>

edited as per @robx advice.

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
sansknwoledge
  • 4,209
  • 9
  • 38
  • 61
  • I suppose there is a css sheet being called with – robx May 22 '11 at 16:23
  • actually the css is in separate file if required i will post the page code. – sansknwoledge May 22 '11 at 16:52
  • I'm pretty aware that it's a separate file which is why i said it sounds like the css sheet is being called with a – robx May 22 '11 at 16:57
  • this is the header section of that page CalibPro <%-- --%> – sansknwoledge May 22 '11 at 17:05
  • 1
    why don't you just edit your post and put it in there instead. would be much easier for everyone to see. – robx May 22 '11 at 17:08

6 Answers6

37

Seems to me like the problem is in your IIS configuration. it might be configured to deliver .css files with text/html MIME type.

Try going to the MIME types configuration on the web server and see if you can spot anything there.

The correct MIME type for .css files is text/css.

You can also have a look on the HTTP header parameters with some HTTP sniffer such as fiddler.

Updating: The accepted answer should be the one pointed by @brett-pennings! Just providing static contents, the error vanished automatically.

Brett Pennings
  • 1,489
  • 14
  • 19
Variant
  • 17,279
  • 4
  • 40
  • 65
  • i am using windows 7 , could u shed some light on how to do that? – sansknwoledge May 23 '11 at 19:21
  • 1
    If you do use IIS, you can just type iis in the start menu's "Search programs and files" field. the first result would be the IIS manager. in the left pane tree, choose your website and then look for "MIME Types" in the Icons in the center panel. – Variant May 23 '11 at 21:38
  • ok , but i dont know what really happened, from yesterday the page started to working normally, i tried to repeat the problem, but unable to do that, so i have to wait, for another time. any way thanks @variant and @robx, i am marking variants as answer. – sansknwoledge May 26 '11 at 07:41
  • 1
    Work for me! Thank you :) – Ta No Bi Aug 20 '16 at 04:46
  • Worked for me as well - serious question, why is IIS not configured to serve static content by *default*? – alex Aug 24 '16 at 13:14
24

Make sure you enable "Static Content" in IIS Windows Features.

IIS Settings

Brett Pennings
  • 1,489
  • 14
  • 19
  • Where is IIS windows features? I have IIS on windows server, I can't seem to find it. – Chirag K Sep 15 '15 at 09:32
  • This is just "Turn Windows features on or off", you'll find these IIS settings in there. What version of Windows are you using? Did you try searching "Windows features" from the start menu? – Brett Pennings Sep 15 '15 at 20:30
4

This is a problem when you are using rewrite url in IIS (in my case it was that), you need to add this entry in your web.config file of your web before the entry of rewrite, something like this:

<rule name="CSS" stopProcessing="true">
    <match url=".css" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" />
    </conditions>
    <action type="None" />
</rule>
<rule name="mod_write" stopProcessing="true">
    <match url="^(.*)$" ignoreCase="true" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="%(REQUES_FILENAME)" matchType="IsDirectory" negate="true" />
        <add input="%(REQUES_FILENAME)" matchType="IsFile" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="false" />
</rule>
Elwi
  • 687
  • 1
  • 5
  • 15
  • Thank you so much! After hours of searching and trying every possible solution, this solved my problem! It had to do with the fact that I was trying to rewrite a directory index but was actually redirecting the entire folder vs one file. THANK YOU! – luv2code Nov 24 '20 at 22:40
1

Oh dear lord! This was one of those errors that seems to come from nowhere... I was scratching my head for almost 1 hour trying to identify what was causing just 1 specific .css file to show a message very similar in Chrome's console window:

Resource interpreted as Stylesheet but transferred with MIME type text/plain

You see it's text/plain instead of text/html.

The file in question was this one:

https://raw.github.com/LPology/Bootstrap-IE7Fix/master/css/bootstrap-ie7fix.css

What I did in Visual Studio 2013 Ultimate was:

  • Right-clicked the project's Content folder and selected Add Style Sheet.
  • Renamed the file to bootstrap-ie7fix.css
  • Copied the full content of the above .css file
  • Pasted the entire content inside Visual Studio and saved the file

Referenced this new file in my Razor view in an ASP.NET MVC app in the exactly same old default fashioned accepted way:

   <link rel="stylesheet" type="text/css" href="/../itvizionlogs/widgets/Content/bootstrap-ie7fix.css">

For any crazy/unknown reason that file would show nothing in Chrome, Firefox, Internet Explorer. What the hell is going on with this file since all other ones in the exact same /Content directory are loading just fine?

My last try was this:

I guess Visual Studio scrambled the encoding of that file initially or something like that!

Tony L.
  • 17,638
  • 8
  • 69
  • 66
Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
0

I don't know whether you developed your project in the framework. i had this mistakes ,when i developed in the ThinkPHP Framework. And the reason is that the frameowrk has some rules about the path of the css file to be include so that if you use the framework ,you can check out whether the framework has its rules for the path of outside css file or javascript file.

0

I had this using webpack-dev-server, it was because of a firewall issue blocking internet access. I initially didn't think it was internet related because I thought I bundled all of my css without depending on external sources. But after digging, I found another css file that was trying to load external fonts from fonts.gstatic.com, this along with my firewall, created my issue.

Post Impatica
  • 14,999
  • 9
  • 67
  • 78