I have the following code in a Razor Helper file
@helper MakeNoteBlank(string content)
{
string msg = "";
if(content == null)
{
msg = " ";
}
else
{
msg = content;
}
<div class="note">
<p>
@Html.Raw(msg)
</p>
</div>
}
The code fails at execution with the @Html.Raw(..) statement, stating that "Object reference not set to an instance of an object."
If I remove the @Html.Raw(..) and output 'msg' directly then there is no problem.
What am I doing wrong?
use @(new HtmlString()) instead of @Html.Raw()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With