Escape-unescape single quote & other characters in client-server communication

Escape in JQuery
var str = escape(txt.val());

Unescape  in Server

Unescape in JQuery
var regionName = unescape(row.RegionName);
Do not use HttpUtility.UrlEncode and HttpUtility.UrlDecode on cookie keys or values.HttpUtility.UrlEncode will improperly escape space characters to '+' and lower case every escape sequence. HttpUtility.UrlDecode will improperly unescape every '+' to a space character. Instead, use System.Uri.EscapeDataString and System.Uri.UnescapeDataString.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s