2011-04-11 70 views
2

我從那裏「用戶」存在主視點調用的RenderPartial上:的RenderPartial呈現上開發,但未能生產服務器

@{Html.RenderPartial("DisplayTemplates/uInfo", user);} 

作品在我的dev的機器,但在生產服務器被折騰的是運行時錯誤的:

未找到部分視圖'DisplayTemplates/uInfo'或沒有視圖引擎支持搜索的位置。以下地點搜索:...

以下地點查詢:上市

~/Views/Account/DisplayTemplates/uInfo.aspx 
~/Views/Account/DisplayTemplates/uInfo.ascx 
~/Views/Shared/DisplayTemplates/uInfo.aspx 
~/Views/Shared/DisplayTemplates/uInfo.ascx 
~/Views/Account/DisplayTemplates/uInfo.cshtml 
~/Views/Account/DisplayTemplates/uInfo.vbhtml 
~/Views/Shared/DisplayTemplates/uInfo.cshtml 
~/Views/Shared/DisplayTemplates/uInfo.vbhtml 

我的文件_is - 共享/ DisplayTemplates/uInfo.cshtml和本地工作。

萬一它是相關的 - 我正在採取在剃刀和遺留.aspx視圖之間來回自由切換的自由。最初擔心混合兩種可能的複雜因素,但到目前爲止,我嘗試過的所有方法都能奏效。

THX

回答

0

它不應該是:

@Html.DisplayFor(model => model.User) 

而如果model.User類型爲uInfo,MVC將在DisplayTemplates文件夾默認外觀和找到uInfo.cshtml。這是工作中的MVC大會。

您不應該使用RenderPartial呈現顯示模板。

如果你想有一個局部視圖,這樣做:

@Html.Partial("SomePartial", user)

不過,我同意你的行爲看到的是奇怪的,這真的doensn't答案問題 - 但嘗試和堅持MVC約定首先。

+0

我已經繼承了代碼,並且無法跟蹤開發該代碼的dev的通過進程(或技能級別)。該調用已在應用中的其他地方工作(旋轉和呈現)。我暫時砍死了它 - 當我有時間時想重新訪問它。謝謝! – justSteve 2011-04-13 01:12:08

相關問題