-1

am building a blog engine using razor/asp.net mvc and I have a text area in which user should enter mainly paragraphs, links and headings. Content of textarea is taken and stored as varchar in db. When I retrieve that content I store it in a string , say content.

When I send this to razor view and do something like @Model.content it simply prints it all as a text. Now is there a simple way to make this work (meaning treat is as html not string) or what would you do in this situation?

nhrnjic6
  • 171
  • 1
  • 1
  • 9

2 Answers2

2

Use @Html.Raw() like below. Hope this will solve your problem.

@Html.Raw((Model.content))
Ibrahim Khan
  • 20,616
  • 7
  • 42
  • 55
0

You should be returning an MvcHtmlString instance instead of string in your model.

See also this previous question and answers what is an mvchtmlstring and when should i use it.

Community
  • 1
  • 1
Igor
  • 60,821
  • 10
  • 100
  • 175