2013-08-02 40 views
0

不同。在我的MVC應用程序,我在我的_Layout.cshtml應用程序資源路徑是從發展和IIS7

它工作在我的開發環境,它解決了設置資源如CSS和JS這樣

<link rel="stylesheet" 
     href="@Url.Content("~/css/external/jquery-ui-1.8.16.custom.css")"/> 
<!-- PLUGIN: jQuery UI styling --> 
<link href="@Href("~/Content/uploadify.css")" rel="stylesheet" /> 
<!-- File uploader --> 

/css/external/jquery-ui-1.8.16.custom.css 

/Content/uploadify.css 

然後,我在IIS7下設置應用程序並將Alias設置爲CommEditor

當我瀏覽它時,所有資源都缺失。

據看着

/CommEditor/css/external/jquery-ui-1.8.16.custom.css 

/CommEditor/Content/uploadify.css 

我應該如何設置的資源,使其適用於開發和IIS7?

回答

0

對於別名,請嘗試在IIS7中設置應用程序的路徑。試試這個:http://www.codeproject.com/Questions/460354/How-to-set-virtual-path-of-my-application-hosted-o

你應該能夠在更新版本的mvc中使用~/folder/resource.ext語法。 〜使用基於應用程序位置的相對路徑。

或者,使用Url.Content("~/folder/resource.ext")如果不起作用,它應該適用於所有版本。

+0

我使用@ Url.Content(「〜/ folder/resource.ext」),它在IIS7下無法工作 – user2617025

+0

@ user2617025我更新了我的答案。 – ps2goat