9

I got this error while working with web app. This is my master page

<head runat="server">
    <link href="Styles/Site.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>

This is the error:

Error: The stylesheet http://localhost:55381/Login.aspx?ReturnUrl=%2fStyles%2fSite.css was not loaded because its MIME type, "text/html", is not "text/css".
Source File: http://localhost:55381/Login.aspx
Line: 0
Mig82
  • 4,856
  • 4
  • 40
  • 63

6 Answers6

12

Looks like your code is requiring a login to access the CSS stylesheet, and returning a HTML login page instead of the CSS.

To verify, try pasting the URL to the stylesheet into your browser, for instance http://localhost:55381/Styles/Site.css - if you get a login page instead of CSS, that's what you need to fix.

David Precious
  • 6,544
  • 1
  • 24
  • 31
  • http://localhost:55381/Styles/Site.css when i paste this URL it is redirecting to Login page as you said...so how to fix this ... i set login page as start page –  Aug 02 '11 at 19:09
  • It's your code; without seeing the code, absolutely no idea! :) – David Precious Aug 02 '11 at 22:03
3

Try this:

<location path="~/Styles">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>

Where Styles is the folder that contains style sheet. I solved it this way

Mig82
  • 4,856
  • 4
  • 40
  • 63
2

@DavidPrecious gave a great answer that led me to the solution.

In my case, the local computer's Users group needed to be given Read permissions to the c:\Inetpub folder in order to allow the static content to be delivered properly.

scott-pascoe
  • 1,463
  • 1
  • 13
  • 31
1

This is more likely an issue at your server side. You request style sheet page Styles/Site.css from the server of type text/css, but your server might be responding to this request with test/html. I had this issue when my server was running in Python and my server was replying to requested css files with header text/html (as that of my index.html file). I re-arranged my server code and assigned the correct headers to its corresponding pages and my issue got resolved.

Mig82
  • 4,856
  • 4
  • 40
  • 63
Anum Sheraz
  • 2,383
  • 1
  • 29
  • 54
0

Another possibility: you've modified your .htaccess file to serve css as html. Maybe something like this, for example:

<filesMatch "\.(htm|html|css|js)$">
ForceType 'text/html; charset=UTF-8'
</filesMatch>

You will want to remove the css from the first line if you've done this.

Mig82
  • 4,856
  • 4
  • 40
  • 63
Scott C Wilson
  • 19,102
  • 10
  • 61
  • 83
0

For me it was an nginx configuration problem, in the file where you declare the path to your static content. I had to move /etc/nginx/mime.types out of the http{} block and further down into where I was serving the static content from. It could similarly be an apache or IIS problem as well, depending on your technology stack.

location / {
   include             /etc/nginx/mime.types;
   root                /path/to/static/content;
   try_files $uri /index.html = 404;
}
Ryan Dines
  • 979
  • 10
  • 18