我在使用Web应用程序时出现此错误,这是我的母版页
<head runat="server">
<link href="Styles/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
Run Code Online (Sandbox Code Playgroud)
错误:样式表http:// localhost:55381/Login.aspx?ReturnUrl =%2fStyles%2fSite.css未加载,因为其MIME类型"text/html"不是"text/css".源文件:http:// localhost:55381/Login.aspx 行:0
Dav*_*ous 11
看起来您的代码需要登录才能访问CSS样式表,并返回HTML登录页面而不是CSS.
要验证,请尝试将样式表的URL粘贴到浏览器中,例如http:// localhost:55381/Styles/Site.css - 如果您获得登录页面而不是CSS,则需要修复此问题.
小智 3
尝试这个:
<location path="~/Styles">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
Run Code Online (Sandbox Code Playgroud)
其中 Styles 是包含样式表的文件夹。我是这样解决的