C# – ASP.NET MVC3 @Html.RenderPartial is throwing CS1502 Error

asp.netasp.net-mvc-3crazor

I'm building an MVC3 app for my dynamic web class, and while attempting to render a partial, I get the following error:

CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)' has some invalid arguments

Now, the code I'm executing is this:

<div>
    <h2>Shipping Address</h2>
    @Html.RenderPartial("_AddressPartial");
</div>

Now, I've googled this, and from what I've seen, the answers are all for older versions of MVC and used the <% %> style syntax and got System.IO errors rather than the System.Web error I'm getting. I did follow their advice though and try with and without the semicolon, which made no difference as I still got the YSOD each time. Any ideas?

Best Answer

This might just be because RenderPartial doesn't return anything. Try either:

@Html.Partial("_AddressPartial")

or

@{ Html.RenderPartial("_AddressPartial"); }