2013-03-21 76 views
0

在MVC中,服务器端目录引用顶部的〜应该转换为网站的根目录。Microsoft MVC4〜扩展不一致

我有我的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> 

公告这个〜被正确地翻译为无,因为它在根上运行,而在最后一行,它没有被翻译,因此没有找到该文件。

这很重要,因为此页面并不总是从网站的根目录运行。

任何帮助,将不胜感激。

+2

这是否与'src =“〜...'中的额外空间有关? – 2013-03-21 20:14:53

回答

0

tereško是对的!领先的空间是失败的原因。非常感谢!