Asp.Net MVC 3 - @Html.Action won't render/return any HTML

本小妞迷上赌 提交于 2019-12-05 05:50:30

Put a Layout = null on the partial view and it will work fine.

Try this:

@{Html.RenderAction("LatestBlogsMainPanelWidget", "Blogs");}

The brain is a funny thing, and despite spending several hours on this yesterday, it took my dog waking me up in the middle of the night for a wee for my subconscious to stumble upon the answer.

If this had anyone else stumped, I'm not surprised. I hadn't mentioned because it hadn't dawned on me that I was using a partial-level caching system similar to one designed by Steve Sanderson. It suddenly struck me that this could be the cause, since to the best of my knowledge Razor pages go through far less pipeline processing than WebForm pages. The caching filter is probably not doing what it needs to do, or at the right time.

I've confirmed that commenting out the OutputCache filter on the Actions in question has fixed the problem.

I've no idea if this issue is true of the page-level caching as it's not something I find useful.

While searching solutions for this issue, I have find out three measure issues for not proper rendering of Html.Action and Html.RenderAction. Please verify have you done below things properly or not.

  1. In your PartialView or View you have defined @{Layout = null;}.
  2. Use return PartialView instead of View .
  3. Decorate your action with [ChildActionOnly] attributes.

I hope by applying above all steps you can solve your issues.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!