Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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

like image 742
ckv Avatar asked Jun 10 '13 15:06

ckv


2 Answers

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

like image 137
Daniel A. White Avatar answered Oct 03 '22 14:10

Daniel A. White


Or use HttpUtility.HtmlDecode

string value1 = "<html>";                 // <html>
string value2 = HttpUtility.HtmlDecode(value1); // <html>
like image 44
wuhcwdc Avatar answered Oct 03 '22 14:10

wuhcwdc