为什么这段代码是正确的:
@{ Html.RenderAction("PostImagesForPost","BlogPost",new { id = Model.ID }); }
而这段代码
@Html.RenderAction("PostImagesForPost",new { id = Model.ID })
通过此错误消息:
Compiler Error Message: CS1502: The best overloaded method match for ‘System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)’ has some invalid arguments
为什么使用'{”}’这么重要?
谢谢
解决方法
@H_502_21@ 必须在脚本块中调用Html.RenderAction,并且无法在标记中调用.@Html.Action("PostImagesForPost",new { id = Model.ID })
有关Action和RenderAction的差异,请参见此处:
http://haacked.com/archive/2009/11/18/aspnetmvc2-render-action.aspx/