It is basically the fact that this format ...
@Html.RenderPartial("MyPartial", Model)
... used for functions that do not return void
, since RenderPartial returns void
, you get this error.
Instead, in this block, it simply executes the code (which will internally execute the write call):
@{ Html.RenderPartial("MyPartial", Model); }
You can alternatively call
@Html.Partial("MyPartial")
... which returns a string.
source share