Error calling @Html.RenderPartial method - CS1502: 'System.Web.WebPages.WebPageExecutingBase.

Posted by Sheonarayan under Error and Solution on 1/23/2015 | Points: 10 | Views : 7713 | Status : [Administrator] | Replies : 0

To call the PartialView in ASP.NET MVC, two methods can be used

@Html.Partial("PartialViewName") and

However, calling @Html.RenderPartial method throws below exception.

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

This exception comes because @Html.RenderPartial returns void as it writes the content of the Partial view in Response stream.

To fix this issue, we need to call the @Html.RenderPartial in the code block under {} in Razor like below.

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

Hope it helps.

Sheo Narayan


(No response found.)

Login to post response