score:2

About the use of Html.Raw and the easy solution:

Change your function to

public static HtmlString DisplayChart(this HtmlHelper helper, ...)
{
    ...
    return new HtmlString(result);
}

You then may use @Html.DisplayChart(...) in your razor views.

Also, please make sure that options.DivName, options.Title, options.SubTitle etc. are properly escaped - a title like Everybody's favorite chart will break the output.


Related Articles