My razor view page looks like:
@foreach (var comment in Model.Comments)
{
@Html.RenderPartial("Comment", comment);
}
And my partial view is in /Shared/Comment.cshtml
@model Comment
<div>
<span class="user">@Model.Name</span>
...
</p>
I’m getting this error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)' has some invalid arguments
(it then highlights the call to @Html.RenderPartial("Comment", comment);
You don’t need the ‘@’ in front of Html since it is stated before any html:
Additionally, Html.RenderPartial doesn’t return anything. So, it must be executed in a code block (the case above counts).
The @[some method] syntax is only valid for methods that return something that Razor can convert to a string.