CSS 没有使用 ASP MVC 项目
CSS isn't working with ASP MVC project
我创建了一个简单的 ASP MVC 视图,但是当我尝试使用 Sass 时,在 firefox 或 chrome 中没有任何反应。当我检查 Chrome 中的页面时,出现以下错误:
Request URL:http://localhost:29120/Views/UI/test.css
Request Method:GET
Status Code:404 Not Found
网络响应是
<head>
<title>The resource cannot be found.</title>
enter code here
</head>
<body bgcolor="white">
<span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>
<h2> <i>The resource cannot be found.</i> </h2></span>
<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
<b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
<br><br>
<b> Requested URL: </b>/Views/UI/test.css<br><br>
<hr width=100% size=1 color=silver>
<b>Version Information:</b> Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34212
</font>
</body>
<!--
[HttpException]: Path '/Views/UI/test.css' was not found.
at System.Web.HttpNotFoundHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->
Index.cshtml
<head>
<link href="~/Views/UI/test.css" rel="stylesheet"/>
<title>title</title>
</head>
我检查了 IIS 目录,文件确实存在。
目前我正在使用 MVS 2013 Ultimate Update 4,所以知道为什么它不起作用吗?
404 响应的原因可能是因为您在 Views 的子目录中有 css 文件。
默认情况下,不会提供 Views 文件夹中的所有文件,因为 Views 文件夹中的 web.config
在 <system.web>
下包含此设置:
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
您可以更改上述设置,但我建议您将 sass 和 css 移到更高级别的目录中。
更多信息:Haacked article
我创建了一个简单的 ASP MVC 视图,但是当我尝试使用 Sass 时,在 firefox 或 chrome 中没有任何反应。当我检查 Chrome 中的页面时,出现以下错误:
Request URL:http://localhost:29120/Views/UI/test.css
Request Method:GET
Status Code:404 Not Found
网络响应是
<head>
<title>The resource cannot be found.</title>
enter code here
</head>
<body bgcolor="white">
<span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>
<h2> <i>The resource cannot be found.</i> </h2></span>
<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
<b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
<br><br>
<b> Requested URL: </b>/Views/UI/test.css<br><br>
<hr width=100% size=1 color=silver>
<b>Version Information:</b> Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34212
</font>
</body>
<!--
[HttpException]: Path '/Views/UI/test.css' was not found.
at System.Web.HttpNotFoundHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->
Index.cshtml
<head>
<link href="~/Views/UI/test.css" rel="stylesheet"/>
<title>title</title>
</head>
我检查了 IIS 目录,文件确实存在。
目前我正在使用 MVS 2013 Ultimate Update 4,所以知道为什么它不起作用吗?
404 响应的原因可能是因为您在 Views 的子目录中有 css 文件。
默认情况下,不会提供 Views 文件夹中的所有文件,因为 Views 文件夹中的 web.config
在 <system.web>
下包含此设置:
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
您可以更改上述设置,但我建议您将 sass 和 css 移到更高级别的目录中。
更多信息:Haacked article