我的 MVC 应用程序中的 index.html
文件包含以下代码。所有文件都会加载到浏览器中,但不会加载 Views 文件夹中的任何文件。
Index.html
文件、Scripts 和 Views 文件夹位于根位置。
<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.js
404 (Not Found)
即使我在 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" />
最佳答案
由于路径不正确, View 可能无法访问脚本文件。
尝试,
<script src="~/Views/Authentication/AuthenticationController.js"></script>
关于javascript - JavaScript 文件 404(未找到),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39410397/