Click here to Skip to main content
15,912,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
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

<b>Hello</b>

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 Asp.net 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
Posted

1 solution

if you are using Razor view engine, you can use
HTML
<text></text>

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

hope this will help you
 
Share this answer
 
v2
Comments
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