MVCContrib 可移植区域不适用于 HtmlExtensions、MVC 3
我刚刚实现了 MVCContrib 的便携式区域功能,它工作正常。我可以使用以下方法打开它: http://localhost/projectname/portableAreaName
,但是如果我使用 HtmlHelper 扩展方法渲染它,这个可移植区域将无法工作,如下所示:
public static void RenderHtmlWidget(this HtmlHelper Html)
{
Html.RenderAction("Index", "HtmlWidget", new {area = "HtmlWidget"});
}
并在视图中调用辅助方法,如下所示:
@using Project.Widgets.HtmlWidget;
@{Html.RenderHtmlWidget();}
我收到错误:未找到视图“索引”或其主视图,或者没有视图引擎支持搜索的位置。在可能的位置列表中没有定义 ~/areas/...。 但我可以使用视图中的同一行代码成功渲染我的 HtmlWidget:
@{Html.RenderAction("Index", "HtmlWidget", new { area = "HtmlWidget" });}
我做错了什么以及如何正确使用 HtmlHelper 扩展与 MVCContrib 可移植区域功能?
I just implemented MVCContrib's Portable Area feature and it works fine. I can open it using:http://localhost/projectname/portableAreaName
, but this portable area is not working if i render it using the HtmlHelper extension method like this:
public static void RenderHtmlWidget(this HtmlHelper Html)
{
Html.RenderAction("Index", "HtmlWidget", new {area = "HtmlWidget"});
}
And calling the helper method in the view as such:
@using Project.Widgets.HtmlWidget;
@{Html.RenderHtmlWidget();}
I'm getting an error: The view 'Index' or its master was not found or no view engine supports the searched locations. In the possible location list there are no ~/areas/... defined.
But I can render my HtmlWidget successfully with this the same line of code in the view:
@{Html.RenderAction("Index", "HtmlWidget", new { area = "HtmlWidget" });}
What am I doing wrong and how should I use the HtmlHelper extensions correctly with the MVCContrib portable areas feature?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一些原因可能会导致这种情况。
There are a few things that may be causing this.