Razor encodes string by default. Is there any special syntax for rendering without encoding?
Demographics. Technologies. Salaries. Career satisfaction.
Since ASP.NET MVC 3, you can use:
|
|||||||||||||
|
|
|||||
|
As well as the already mentioned @Html.Raw(string) approach, if you output an MvcHtmlString it will not be encoded. This can be useful when adding your own extensions to the HtmlHelper, or when returning a value from your view model that you know may contain html. For example, if your view model was:
then
|
|||
|
Use
Then you have peace of mind that you haven't created a potential security hole and any special/foreign characters are displayed correctly in all browsers. |
|||||
|
You can also use the WriteLiteral method |
|||
|
In case of ActionLink, it generally uses HttpUtility.Encode on the link text.
In that case
you can use
|
|||||
|
HTML RAW : @Html.Raw(yourString) |
|||
|