Asp.Net MVC 3 - @ Html.Action不会渲染/返回任何HTML [英] Asp.Net MVC 3 - @Html.Action won't render/return any HTML

查看:291
本文介绍了Asp.Net MVC 3 - @ Html.Action不会渲染/返回任何HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从ViewPages今天提出一个相当新的项目,剃刀,一切似乎都很顺利。除了我试图用Html.Action呈现一个用户控件,它不会呈现任何内容。

I've been moving a fairly new project from ViewPages to Razor today, and all seems to be going well. Except I'm trying to use Html.Action to render a user control and it won't render anything.

所以,我这是在主页/ Index.cshtml引用的共享/ _Layout.cshtml文件

So I have a Shared/_Layout.cshtml file which is referenced in Home/Index.cshtml

Index.cshtml有以下几点:

Index.cshtml has the following:

<article>

@Html.Action("LatestBlogsMainPanelWidget", "Blogs")

...

</article>

我已经把陷阱在BlogsController,所以我知道这是被请求。我也知道,被返回的模式,即LatestBlogsMainPanelWidget正在由视图引擎发现,甚至一些虚拟剃刀语法code正在运行:
@ {
变种s =你好;
}

I've put traps in the BlogsController, so I know that's being requested. I also know that a model is being returned, that the LatestBlogsMainPanelWidget is being found by the view engine, and even some dummy Razor syntax code is being run: @{ var s = "hello"; }

但在这个文件中的纯HTML是不是做给浏览器。我试过其他的(previously工作)的谐音也和(页面确认它不存在查看源代码),他们将不会出现任何

but the plain html in this file isn't making it to the browser. I've tried other (previously working) partials too and they won't appear either (view source on the page confirms it's not there).

我也试过代替
@ {Html.RenderAction(...); } 没有成功。 HTML无论是@ Html.Action的一侧出现,所以我知道Index.cshtml能否正常显示。

I've also tried substituting for @{ Html.RenderAction(...); } without success. HTML either side of the @Html.Action is appearing, so I know Index.cshtml is displaying properly.

更诡异的_layout文件也有Html.Action命令和他们的显示正常。

Even more strangely the _Layout file also has Html.Action commands and they do appear fine.

我真的不知道要检查些什么,或者如何确认该管道获得HTML。谁能帮助呢?

I'm really not sure what else to check, or how to confirm that the pipeline is getting the HTML. Can anyone help at all?

谢谢!

推荐答案

大脑是一个有趣的事情,尽管这个昨天花费好几个小时,花了我的狗叫醒我在半夜为一个凌晨我的潜意识在回答绊倒。

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.

如果这有任何人难住了,我并不感到惊讶。我没有提到,因为它没有对我醒悟过来,我用类似一个由史蒂夫·桑德森设计了部分级别的缓存系统。我突然想到,这可能是原因,因为尽我所知剃刀的网页通过远不如流水线处理比Web窗体页。缓存过滤器可能不是做什么,它需要做的,或者在合适的时间。

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.

我已经证实,注释掉有问题的操作中的OutputCache过滤器已经解决了这一问题。

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.

这篇关于Asp.Net MVC 3 - @ Html.Action不会渲染/返回任何HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆