Cannot render css in ASP.NET
I modified main.min.css and main.full.css (setting another color of background) and page now cannot render css. It's just a HTML.
Master page: (shortened version with links)
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="ZASshop.master.cs" Inherits="ZASshop.NET.ZASshop" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Assembly="ZAScontrols" Namespace="ZAScontrols" TagPrefix="zas" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="MasterHead" runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="/App_Firma/css/main.min.css" rel="stylesheet" type="text/css" media="screen" />
<link href="/App_Firma/css/firm.css" rel="stylesheet" type="text/css" media="screen" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
<link href="/App_Firma/DayPilot/Themes/scheduler_8.css" rel="stylesheet" type="text/css"/>
<link href="/App_Firma/css/custom.css" rel="stylesheet" type="text/css" media="screen"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
at the end of this file link to script:
<script src="/App_Firma/js/app.min.js"></script>
and I also got a warnings and error in Chrome console:
LoginPage.aspx:7 Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/LoginPage.aspx?ReturnUrl=%2fApp_Firma%2fcss%2fcustom.css". LoginPage.aspx:7 Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/LoginPage.aspx?ReturnUrl=%2fApp_Firma%2fcss%2ffirm.css". LoginPage.aspx:7 Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/LoginPage.aspx?ReturnUrl=%2fApp_Firma%2fcss%2fmain.min.css". LoginPage.aspx:7 Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/LoginPage.aspx?ReturnUrl=%2fApp_Firma%2fDayPilot%2fThemes%2fscheduler_8.css". LoginPage.aspx?ReturnUrl=%2fApp_Firma%2fjs%2fapp.min.js:2 Uncaught SyntaxError: Unexpected token <
Change:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-
awesome/4.6.1/css/font-awesome.min.css">
to
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-
awesome/4.6.1/css/font-awesome.min.css" type="text/css"/>
you need to close the label with '/'
check this post too, seems to be the same problem:
Resource interpreted as Stylesheet but transferred with MIME type text/html in ASP.NET IIS
You must add .css MIME type with text/css value into IIS. Currently, the web server does not understand what .css means.
This will work when the content-type response header value is set to text/css.
You need to exclude the css files and images from getting authenticated as following in the configuration file. Using the location tag you can exclude a single file or a directory.
<location path="<relatevie path of your css files>">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
链接地址: http://www.djcxy.com/p/47020.html
上一篇: Mime键入Google Chrome中的zip文件
下一篇: 无法在ASP.NET中呈现css