从不同的文件夹C#调用html partial

时间:2015-02-05 14:37:24

标签: c#

我有以下DIR结构:

Public
--mobile
----Views
------UK
--------Recipes
----------ViewRecipePlain.cshtml // pull this
--mobilePublic
----Views
------UK
--------Recipes
----------ViewRecipe.cshtml // into this

我想从ViewRecipePlain.cshtml

中拨打ViewRecipe.cshtml

在ViewRecipe.cshtml内部我正在尝试:

@Html.Partial("../../../../mobile/Views/UK/Recipes/ViewRecipePlain")

但我得到了错误:

Cannot use a leading .. to exit above the top directory.

还有其他办法吗?

更新

我也尝试过:

@Html.Partial("~/mobile/Views/UK/Recipes/ViewRecipePlain.cshtml")

但是得到以下错误:

The partial view '~/mobile/Views/UK/Recipes/ViewRecipePlain.cshtml' was not found or no view engine supports the searched locations. 
The following locations were searched:
~/mobile/Views/UK/Recipes/ViewRecipePlain.cshtml

还要更新DIR结构,以便更加准确,如果它有所作为,但怀疑它确实如此。

1 个答案:

答案 0 :(得分:2)

您可以使用视图的绝对路径:

@Html.Partial("~/mobile/Views/UK/Recipes/ViewRecipePlain.cshtml")