问题描述
我一直试图找出 RenderAction 和 Action 之间的区别.我不知道在这一点上我是否如此关心差异,至于为什么我不能让 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)'有一些无效的参数.
任何提示或提示?我什至不应该为 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()
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.
代替
@Html.RenderAction()
使用
@{Html.RenderAction();}
这篇关于Html.Action 和 Html.RenderAction 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!