css was not loaded because its MIME type, “text/html”, is not “text/css”.

≡放荡痞女 提交于 2019-12-22 04:06:37

问题


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>

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


回答1:


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.




回答2:


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

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




回答3:


@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.




回答4:


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 would want to remove the "css" from the first line if you've done this.)




回答5:


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.



来源:https://stackoverflow.com/questions/6915338/css-was-not-loaded-because-its-mime-type-text-html-is-not-text-css

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!