[英]Umbraco mvc, rendering partial view cannot be resolved to a type
I have a partial view located in ~/Views/Partials/menubar.cshtml
. 我在
~/Views/Partials/menubar.cshtml
有一个局部视图。
In my ~/Views folder i have a master page Called Menubar.cshtml
<- this masterpage calls the @{ Html.RenderPartial("menubar") }
but it says: 在我的〜/ Views文件夹中,有一个名为
Menubar.cshtml
的母版页<-该母版页名为@{ Html.RenderPartial("menubar") }
但它说:
"Cannot resolve partial view "menubar"
“无法解决部分视图的“菜单”
How can i fix this? 我怎样才能解决这个问题? I've tried the direct path like
我已经尝试过像
@{ Html.RenderPartial("~/Views/Partials/menubar.cshtml") }
still the same issue. @{ Html.RenderPartial("~/Views/Partials/menubar.cshtml") }
仍然是同一问题。
It has to be said that im using Umbraco 4.11 and Visual studio 2012 with resharper. 必须说的是,即时通讯使用Umbraco 4.11和带有reshaper的Visual Studio 2012。
Here is the code for my masterpage (it has another masterpage): 这是我的母版页代码(它还有另一个母版页):
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = "Master.cshtml";
}
<div id="header">
<a href="/"><img src="/images/logo.gif" width="259" height="65" /></a>
<div id="sitedescription">
<h1>Runway</h1>
<h1>Off to a great start</h1>
</div>
@{ Html.RenderPartial("Menubar"); }
</div>
@RenderBody()
This is the code for my view, simplified just to get it working at first, there will be added some logic, otherwise the view would not make sense to have: 这是我的视图的代码,简化后只是为了使其首先工作,将添加一些逻辑,否则视图将没有意义:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
<div id="mainmenu">
<ul id="topNavigation">
<li class="home current"><a href="/">Home</a></li>
<li><a class="navigation" href="/"><span>Newz</span></a></li>
<li><a class="navigation" href="/"><span>Programmering</span></a></li>
<li><a class="navigation" href="/"><span>Support</span></a></li>
<li><a class="navigation" href="/"><span>Repair</span></a></li>
</ul>
</div>
<div class="mainmenucorner"> </div>
Here is an image of the structure in visual studio: 这是Visual Studio中的结构图:
Can anyone tell me what i'm missing here, have spend hours on this now. 谁能告诉我我在这里想念的东西,现在就花几个小时。
EDIT I've found out that id i locate it under /Views/Shared it'll find it automatically.. It just seems that umbraco posts this page as the main page then - any thougts? 编辑我发现我在/ Views / Shared下找到它的ID,它会自动找到它。.似乎umbraco将此页面发布为主页,然后-有什么想法吗?
Try renaming the partial to _menuBar.cshtml, and render it using this: 尝试将部分名称重命名为_menuBar.cshtml,并使用以下方式呈现它:
@Html.Partial("_menuBar")
It works for me. 这个对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.