.net - How do I allow selective HTML input in my ASP.NET MVC application? -


i'd end-user type in text without formatting in text area in asp.net mvc application. however, retain line breaks or paragraphs have created when typing in text.

if use textarea without allowing html input, default, line breaks , paragraphs not retained when text saved database or read displayed on user interface.

if allowhtml, run risk of code injection.

the other way can think of implementing not allowhtml instead have custom attribute checks allows <p> tags , <br /> tags, implementing that, simple might seem, have maintain dictionary of possible html tags and, nature of web being volatile, god knows other syntactical tokens css or something.

am over-complicating issue? there out of box or there easier way implement this?

i using asp.net mvc 5.2.3 targeting asp.net 4.5.

textarea keeps line breaks \n characters. when displaying value afterwards outside textarea element part of page '\n' characters need replaced '<br />'.


Comments