string HTMLContent = @Server.HtmlDecode("<div>Hello World</div>");
var StaticHTML = @HTMLContent;
Uncaught SyntaxError: Unexpected token &
When razor executes the code in your view,
@ will encode the value of your C# expression. So you want to avoid doing that. You may use
Html.Raw method which does not do any html encoding.
Since you are assigning the value to the js variable, you should wrap it in quotes(single or double).
This should work.
var StaticHTML = "@Html.Raw(HTMLContent)"; console.log(StaticHtml);