我创建了一个简单的ASP MVC View但是当我尝试使用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,所以不知道为什么它不起作用?
答案 0 :(得分:1)
404响应的原因可能是因为您在视图的子目录中有css文件。
默认情况下,由于web.config
下包含此设置的Views文件夹中的<system.web>
,因此不会投放Views文件夹中的所有文件:
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
您可以更改上述设置,但我建议您将sass和css移到更高级别的目录中。
更多信息:Haacked article