Reputation: 824
I'm making simple article adding. I have a CKEditor and I take from this data and encode it with encodeURI
in javascript and send it to ViewController then I put it into table in database. Then I want to show the article, so I <% HTML.RenderAction("MyAction); %>"
and in this action I decode the url from database using HttpUtility.UrlDecode(content)
. But it shows for example HTML tags instead of being formatted. It is shown as a text. When in Chrome I click right and show HTML then there are words like :
& lt; p > ; Some text here< ; / p & g t;
There is no space in between characters I added them because it shows
<p></p>
What can I do to make it working properly?
Upvotes: 0
Views: 1184
Reputation: 10927
Since you are decoding the html and not the url, you need to use HttpUtility.HtmlDecode
.
HttpUtility.UrlDecode
does not know how to deal with html tags, only with a url format, so trying url decode on html will provide someting like:
& lt; p > ; Some text here< ; / p & g t;
Which is the string representation of the html, which basically, is proving that what it is doing is actually correct, because it is decoding, just not in the format you need. Cocnlusion is:
HttpUtility.HtmlDecode
Upvotes: 0
Reputation: 1101
HttpUtility.HtmlDecode
,not HttpUtility.UrlDecode
@Html.Raw()
to show your contentUpvotes: 1