Html.Action和Html.RenderAction之间的差 [英] The difference between Html.Action and Html.RenderAction

查看:463
本文介绍了Html.Action和Html.RenderAction之间的差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图找出RenderAction和行动之间的区别。我不知道如果我那么在意的差异在这一点上,至于为什么我不能让RenderAction工作。从我可以告诉,我传递正确的参数。我使用过载似乎是相同的两个:

I've been trying to figure out the difference between RenderAction and Action. I don't know if I'm so concerned about the differences at this point, as to why I can't get RenderAction to work. From what I can tell, I'm passing in the correct parameters. The overload I'm using seems to be the same for both:

@Html.RenderAction(Action, Controller, Route)

@Html.Action("Breadcrumb", "Navigation", new {SeoUrl = Model.CarlineBucket.SEOURLName})

@Html.RenderAction("Breadcrumb", "Navigation", new {SeoUrl = Model.CarlineBucket.SEOURLName})

我得到一个编译错误,当我尝试使用RenderAction:

I get a compilation error when I try and use RenderAction:

CS1502:最好的重载方法   匹配   System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)'   有一些无效的参数。

CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)' has some invalid arguments.

任何提示或提示吗?我应该甚至不打扰与RenderAction?

Any tips or hints? Should I not even be bothering with RenderAction?

推荐答案

尝试:

@{Html.RenderAction("Breadcrumb", "Navigation", new {SeoUrl = Model.CarlineBucket.SEOURLName})}

@ Html.RenderAction()生成你不这样做在页面上,你的情况写调用输出一些事情,因为 RenderAction 直接呈现结果的回应。如果你会使用 @ {Html.RenderAction()} 它应该工作。

@Html.RenderAction() generates a write call to output something on the page and in your case you are not doing so because RenderAction renders the result directly to the Response. if you'll use @{Html.RenderAction()} it should work.

这篇关于Html.Action和Html.RenderAction之间的差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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