我刚刚创建了一个新的 ASP.Net MVC3 项目,它不会从 Scripts 文件夹加载任何脚本,当我调试时给我一个 404。
我到底该如何解决这个问题?
包括这样的:
<script type="text/javascript" src="../../Scripts/jquery.validationEngine.js"></script>
<script type="text/javascript" src="../../Scripts/languages/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="../../Scripts/bootstrap-transition.js"></script>
<script type="text/javascript" src="../../Scripts/bootstrap-alert.js"></script>
<script type="text/javascript" src="../../Scripts/bootstrap-modal.js"></script>
或在 App_Code 中使用全局变量,如下所示:
public static readonly string JSDir = "../../Scripts";
在我看来:
<script type="text/javascript" src="@GlobalVal.JSDir/jquery.validationEngine.js"></script>
<script type="text/javascript" src="@GlobalVal.JSDir/languages/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="@GlobalVal.JSDir/bootstrap-transition.js"></script>
<script type="text/javascript" src="@GlobalVal.JSDir/bootstrap-alert.js"></script>
<script type="text/javascript" src="@GlobalVal.JSDir/bootstrap-modal.js"></script>
也试过这个:
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.validationEngine.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/languages/jquery.validationEngine-en.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/bootstrap-transition.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/bootstrap-alert.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/bootstrap-modal.js")"></script>
无论哪种方式,结果都是一样的。404 脚本文件夹中的所有文件。