Razor partial view – Html.RenderPartial – Cannot implicitly convert type ‘void’ to ‘object‘

Razor Html.RenderPartial “Cannot implicitly convert type ‘void’ to ‘object’.”
When I tried to render my partial view with a standard call I got a compile time error saying “Cannot implicitly convert type ‘void’ to ‘object’.”

The reason behind this compile time error was the RenderPartial() call renders its result directly to the response object and cannot be used like a simple string result.

To resolve the issue, all you have to do is enclose the call in a code block.

{Html.RenderPartial

Advertisements

4 thoughts on “Razor partial view – Html.RenderPartial – Cannot implicitly convert type ‘void’ to ‘object‘

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s