jgd1234567
Programmer
Hi, i'm coming from a php background where everytime i posted a variable back to the server i would wrap in a function before passing into my sql statement. This allowed me do a replacement for html entities and also a mysql fix to avoid sql injections.
With asp.net if i use parameters i avoid any sql injections but i still have problems with html entities.
Say in the edit profile area of my site i have a formview which uses 2 way databinding and contains a textbox for the user's first name. Then say i wrap the value (when posted back) with Server.HtmlEncode before updating the value in the database. If the user entered <a test the next time the user edits their profile it says <a test since the textbox control also does its own encoding. I could decode the value before binding it within my textbox but this is a very hacky solution.
My next idea was not to encode the text at all in the database and instead only encode the text where it is outputted on the site. This seems to work but i'm not sure if this is secure enough since i would have to remember to encode the data everytime i display it.
I'm sure people have had similar problems and i would really really appreciate your solution. Thanks
With asp.net if i use parameters i avoid any sql injections but i still have problems with html entities.
Say in the edit profile area of my site i have a formview which uses 2 way databinding and contains a textbox for the user's first name. Then say i wrap the value (when posted back) with Server.HtmlEncode before updating the value in the database. If the user entered <a test the next time the user edits their profile it says <a test since the textbox control also does its own encoding. I could decode the value before binding it within my textbox but this is a very hacky solution.
My next idea was not to encode the text at all in the database and instead only encode the text where it is outputted on the site. This seems to work but i'm not sure if this is secure enough since i would have to remember to encode the data everytime i display it.
I'm sure people have had similar problems and i would really really appreciate your solution. Thanks