rendering html from cs file to cshtml

c#, html, razor

Solution

<div>
    @Html.Raw(class1.createhtml())
</div>

You should be very careful that you don't put unescaped user-input into this string, or you open up the door to injection attacks - treat this with the caution that you might treat appending strings to make a SQL query: avoid it if at all possible, or be very careful.

Problem

I'm creating some html code from a cs file, which i want to be rendered one the actual site. But what I get rendered is the "raw" html code, not the rendered. What am I doing wrong? the .cshtml code: ``` <div> @class1.createhtml(); </div> ``` the .cs code: ``` public static string createhtml() { return "<p>hi</p>"; } ```

Original source