Skip to content

Calling RenderPartial inside of a Razor helper results in the contents of the partial view being html encoded #35

@mikdav

Description

@mikdav

Minimal example below.

MainView.cshtml:
@helper RenderSomething()
{
<div>@RenderPartial("PartialView")</div>
}
<html><body>@RenderSomething()</body></html>

PartialView.cshtml:
<table><tr><td>Hello World</td></tr></table>

Expected output:
<html><body><div><table><tr><td>Hello World</td></tr></table></div></body></html>

Actual output:
<html><body><div>&lt;table&gt;&lt;tr&gt;&lt;td&gt;Hello World&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</div></body></html>

The problem appears to be that RazorTemplateBase.WriteTo is not respecting IHtmlString or RawString. I'll submit a pull request with a fix that worked for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions