Differences in RenderAction

Why is this code correct:

@{ Html.RenderAction("PostImagesForPost", "BlogPost", new { id = Model.ID }); } 

And this code

  @Html.RenderAction("PostImagesForPost", "BlogPost", new { id = Model.ID }) 

through this error message:

Compiler Error Message: CS1502: Best Overloaded Method Compliance for "System.Web.WebPages.WebPageExecutingBase.Write (System.Web.WebPages.HelperResult)" contains some invalid arguments

Why is it so important to use '{' '}'?

thanks

+7
c # asp.net-mvc razor renderaction
source share
1 answer

Html.RenderAction must be called in a script block and cannot be called in markup.

As an alternative to markup, you will use:

 @Html.Action("PostImagesForPost", "BlogPost", new { id = Model.ID }) 

For differences on Action and RenderAction see here:

http://haacked.com/archive/2009/11/18/aspnetmvc2-render-action.aspx/

+4
source share

All Articles