【发布时间】:2016-09-09 11:19:23
【问题描述】:
来自 MVC 应用程序的我的 index.html 文件包含以下代码。所有文件都加载到浏览器中,但没有加载 Views 文件夹中的文件。
Index.html 文件、脚本和视图文件夹位于根位置。
<body>
<div ng-view></div>
<script src="Scripts/jquery-1.9.1.min.js"></script>
<script src="Scripts/angular.min.js"></script>
<script src="Scripts/angular-route.min.js"></script>
<script src="Scripts/app.js"></script>
<script src="Views/Authentication/Services.js"></script> -- Error here
<script src="Views/Authentication/AuthenticationController.js"></script> -- Error here
</body>
文件夹结构
当我从 chrome devtool 检查时收到以下错误消息。
http://localhost:58348/Views/Authentication/AuthenticationController.js404(未找到)
即使我在 web.config 中添加了 js/html 处理程序,但仍然面临同样的问题。
<add name="JavaScriptHandler" path="*.js" verb="*" preCondition="integratedMode"
type="System.Web.StaticFileHandler" />
<add name="HtmlScriptHandler" path="*.html" verb="*" preCondition="integratedMode"
type="System.Web.StaticFileHandler" />
【问题讨论】:
-
我认为是路径的问题。
Scripts/Vies...也许? -
您的脚本在 Views 文件夹还是 Scripts 文件夹中?
-
Index.html 文件,Scripts & Views 文件夹位于根目录。