10

Does ASP.NET MVC razor view engine encode HTML by default?

Or do we have to use the htmlhelpers for html encoding the data.

1

2 Answers 2

14

Yes it does. Use @Html.Raw(...) to break that behavior.

Sign up to request clarification or add additional context in comments.

Comments

1

Or use HttpUtility.HtmlDecode

string value1 = "<html>";                 // <html>
string value2 = HttpUtility.HtmlDecode(value1); // <html>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.