Westwind.RazorHosting icon indicating copy to clipboard operation
Westwind.RazorHosting copied to clipboard

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

Open mikdav opened this issue 5 years ago • 1 comments

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.

mikdav avatar May 30 '19 12:05 mikdav

@RickStrahl Any chance you can take a look at my proposed fix? Any help would be greatly appreciated.

mikdav avatar Jun 14 '19 13:06 mikdav