Monday 8 June 2015

Display encoded string into html in razor asp.net

There are various way to do it,
a. by using html helper Raw() function
b. We have MvcHtmlString to do this and
c. Direct creation of HtmlString instance


@{
var rawHtml= "<a href='/....html'>demo</a>";
}


@Html.Raw( rawHtml )
@MvcHtmlString.Create( rawHtml )
@( new HtmlString(_m._Static.GetAd ( rawHtml )

Output:-
demo