The reason I think I need it, is because I'm displaying text I get from websites in a Windows 8 store app. E.g.
é should become
Or is there a better way? I'm not displaying websites or rss feeds, but just a list of websites and their titles.
I am trying to encode special character in html attribute using C#
When I encode this following string
var encode1= HttpUtility.HtmlEncode("Student on \" On the Rise \"");
the encoding generates the correct output, like this:
Student on " On the Rise "
The browser encodes the
& and again and generate wrong encoding as follow
<meta property="og:title" content="Student on &quot; On the Rise &quot;" />
How can I tell the browser not to encode the
& character again?
Every time a user posts something containing
> in a page in my web application, I get this exception thrown.
I don't want to go into the discussion about the smartness of throwing an exception or crashing an entire web application because somebody entered a character in a text box, but I am looking for an elegant way to handle this.
Trapping the exception and showing
An error has occurred please go back and re-type your entire form again, but this time please do not use <
doesn't seem professional enough to me.
Disabling post validation (
validateRequest="false") will definitely avoid this error, but it will leave the page vulnerable to a number of attacks.
Ideally: When a post back occurs containing HTML restricted characters, that posted value in the Form collection will be automatically HTML encoded.So the
.Text property of my text-box will be
something & lt; html & gt;
Is there a way I can do this from a handler?
I have a textfield which displays a string which contains < and >. The code throws an error because of that. How can I allow the usage of those chars in my textfield?
I need to write a method which takes any object and returns an equivalent object but by applying html-encode on all public writable string properties/fields if the object is a reference type. If the object is a string it should obviously return html-encode of the string passed. If it's an enumerable type it should enumerate the type and apply the same logic as above on each of the items in the list.
Does this even sound possible ? I've been toying with some code (using ObjectDumper.cs as the starting point) but haven't been able to get far.
The idea is that i can then apply this as an aspect to all my service methods, such that the returning object fields are safe to be bound with html ui, which is being worked on by several people who sometimes forget triggering the encode on the client side.