Click here to Skip to main content
14,739,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have make a messaging system in which user can send messages to each other, they can also send files as attachement in message(its like simple email system). It allows users to send HTML characters and they'll render by browser, for eg if they enter


it'll rendered as Hello

Its working fine,however i am facing one problem if user enter

<iframe src="anywebsite"><iframe>
then it'll also rendered by browser as iframe

How can i allow only some particular characters to be rendered by browser rest will display as normal text I am using MVC3

In my model class i've add
[AllowHtml] attribute to allow HTML characters

I've used HtmlSanitization Library[^] to render save HTML but in case of iframe it is rendering nothing and i want to display iframe as plain text

1 solution

if you are using Razor view engine, you can use

otherwise you can also use
<pre lang="HTML">

hope this will help you
Syed Salman Raza Zaidi 6-Apr-12 7:15am
I am using Razor Engine,so what i can use?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900