Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, February 11, 2015 9:05 PM
I am creating news items with a text editor and save them to SQL. In SQL I confirm that HTML tags are being saved for example <b>Title</b> and <p> Post content</p> in my application officeNews.cshtml I have the following code
@foreach (var item in Model)
{
...
<p>
<span class="label label-info">@Html.ActionLink(@Html.DisplayFor(modelItem => item.date).ToString(), "Index", new { sortOrder = ViewBag.DateSortParm })</span>
@Html.Raw(HttpUtility.HtmlDecode(item.postContent));
</p>
<p>@Html.DisplayFor(modelItem => item.author)</p>
<h6>Category: @Html.DisplayFor(modelItem => item.category)</h6>
</div>
</div>
For some reason When I run locally from visual studio, it works fine, i.e Test , but when I publish to Azure HTML tags are showing <strong>Test</strong>
before I was using @Html.DisplayFor(modelItem =>item.postContent); Which did not work. and @Html.Raw(item.postContent)) did not work either both locally and remote What can I do to make this work?
Thank you for your help
All replies (4)
Thursday, February 12, 2015 9:38 PM âś…Answered
Hi jaydee,
Based on your code, didn't find the problem from the surface.
I suggest you to try the below code:
@Html.Raw(HttpUtility.HtmlDecode("<strong>Test</strong>"));
Don't use the value from variable. I suspected there was some strange thing in your value. i.e space, special signs.
Hope this can be helpful to you.
Sherwin Zhao
Best Regards
Wednesday, February 11, 2015 9:45 PM
I have a similar project, and I am just using the equivalent to @Html.Raw(item.postContent)
Wednesday, February 18, 2015 5:59 PM
Did you end up getting this issue working? If any of the posts helped you solving the issue, then please mark it as an answer, otherwise you can post your solution and mark it as an answer so that other people with similar issue can easily find the solution
Wednesday, February 18, 2015 7:05 PM
Thanks it worked with @Html.Raw(HttpUtility.HtmlDecode(item.postContent)) .