【问题标题】:main.css was not loaded because its MIME type, “text/html”, is not “text/css”?main.css 没有加载,因为它的 MIME 类型“text/html”不是“text/css”?
【发布时间】:2018-03-30 05:45:17
【问题描述】:

SA

我知道这个问题已经有多个答案,但没有一个对我有用,因为我的有点奇怪。

基本上我有几个页面说:

index.html
contacts.html
find.html

header.html // main.css files contains  styling for this header file which is dynamically loaded into different pages.

问题是,当我将头文件加载到 index.htmlcontacts.html 时,它加载正常,但是当我在 find.html 加载它时,它会弹出浏览器控制台错误消息:

Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# instead[Learn More]  JquerySock.js:1
The stylesheet http://localhost:20012/Duck/main.css was not loaded because its MIME type, “text/html”, is not “text/css”. search
The stylesheet http://localhost:20012/Duck/CSS/search.css was not loaded because its MIME type, “text/html”, is not “text/css”. search
The stylesheet http://localhost:20012/Duck/mainelements/aside.css was not loaded because its MIME type, “text/html”, is not “text/css”.

另外,请求标头content-type 恰好是text/css,但响应却是text/html 不知道为什么。 仅供参考:我正在使用 Debian (Jessie)。 Firefox ESR v52.4.0

【问题讨论】:

    标签: javascript html css firefox


    【解决方案1】:

    看起来您的代码需要登录才能访问 CSS 样式表,并返回 HTML 登录页面而不是 CSS。

    这里的 'Styles' 是包含 css 的文件夹。

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

    【讨论】:

    • 我知道你复制粘贴了这个答案。无论如何,我可以以http://localhost:20012/Duck/main.css 作为url 链接访问我的样式表。顺便说一句,你把代码放在哪里?
    • 是的,我复制了..对不起,我忘记放链接了。
    猜你喜欢
    • 2017-09-17
    • 2021-12-29
    • 2020-06-22
    • 2018-07-08
    • 2011-01-12
    • 2020-11-30
    • 2017-06-05
    • 2020-11-03
    相关资源
    最近更新 更多