.NET MVC视图被命中,但没有渲染到页面

时间:2022-04-09 15:19:08

I'm using Sitecore 8.0 if that matters (it probably does), but in my stock project I have the main layout being rendered, the layout being hit with a few

我正在使用Sitecore 8.0,如果这很重要(它可能会),但在我的库存项目中,我有主要的布局被渲染,布局受到一些打击

@{Html.Action();}

Method calls in my view. I can see the controller being hit. And if I breakpoint in those nested views I can see those being hit, however when the page is rendered ... nothing! Only the layout is rendered. My dummy test, "This is a test from a partial view" is not rendered even if I put a breakpoint to see what's going on I can confirm that it is actually being invoked. I'm stumped, any thoughts?

在我的视图中调用方法。我可以看到控制器被击中。如果我在那些嵌套视图中断点,我可以看到那些被击中,但是当页面被渲染时......什么都没有!仅渲染布局。我的虚拟测试,“这是一个部分视图的测试”,即使我放置一个断点来查看发生了什么,我也可以确认它实际上是被调用的。我很难过,有什么想法吗?

2 个解决方案

#1


4  

You need to render your view. This will automatically invoke the action:

您需要渲染视图。这将自动调用操作:

@Html.RenderAction("action");

#2


0  

Html.RenderAction() will render the result directly to the response but will give you better performance.

Html.RenderAction()将直接将结果呈现给响应,但会为您提供更好的性能。

Html.Action("Action Name", "Controller Name") will return a string with result.

Html.Action(“Action Name”,“Controller Name”)将返回带有结果的字符串。

Have you been able to get the text rendered now? Have you got a placeholder and is it lowercase? Charlie :)

你现在能够获得文本吗?你有一个占位符,它是小写的吗?查理:)

#1


4  

You need to render your view. This will automatically invoke the action:

您需要渲染视图。这将自动调用操作:

@Html.RenderAction("action");

#2


0  

Html.RenderAction() will render the result directly to the response but will give you better performance.

Html.RenderAction()将直接将结果呈现给响应,但会为您提供更好的性能。

Html.Action("Action Name", "Controller Name") will return a string with result.

Html.Action(“Action Name”,“Controller Name”)将返回带有结果的字符串。

Have you been able to get the text rendered now? Have you got a placeholder and is it lowercase? Charlie :)

你现在能够获得文本吗?你有一个占位符,它是小写的吗?查理:)