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>
公告這個〜被正確地翻譯爲無,因爲它在根上運行,而在最後一行,它沒有被翻譯,因此沒有找到該文件。
這很重要,因爲此頁面並不總是從網站的根目錄運行。
任何幫助,將不勝感激。
這是否與'src =「〜...'中的額外空間有關? – 2013-03-21 20:14:53