在MVC中,服务器端目录引用顶部的~应该转换为网站的根目录。
我的cshtml文件的顶部有以下几行:
<link rel="STYLESHEET" type="text/css" href="~/codebase/dhtmlxgrid.css">
<script src="~/codebase/dhtmlxcommon.js"></script>
<script src="~/codebase/dhtmlxgrid.js"></script>
<script src="~/codebase/dhtmlxgridcell.js"></script>
<script src ="~/IactexScripts/WorkOrderAdd.js"></script>当代码运行时,我在发送到浏览器的输出中得到以下内容:
<link rel="STYLESHEET" type="text/css" href="/codebase/dhtmlxgrid.css">
<script src="/codebase/dhtmlxcommon.js"></script>
<script src="/codebase/dhtmlxgrid.js"></script>
<script src="/codebase/dhtmlxgridcell.js"></script>
<script src ="~/IactexScripts/WorkOrderAdd.js"></script>注意,~被正确地转换为空,因为这是在根目录上运行的,而在最后一行,它没有被转换,因此,没有找到文件。
这一点很重要,因为这个页面并不总是从网站的根目录运行。
任何帮助都将不胜感激。
发布于 2013-03-22 23:21:46
tereško是对的!前导空格是导致失败的原因。非常感谢!
https://stackoverflow.com/questions/15557003
复制相似问题