views:

108

answers:

2

While adding the parameters to get/post request they need to be encoded in application/x-www-form-urlencoded form. So do we need to encode values each time ? Does JavaScript have any method for that ? What are the possible caches ?

On server side when we read the values we do not decode them we directly say Request.Params["key"] and that returns value. Does that mean that they are automatically taken care when we read the values?

+1  A: 

You can (and should) use encodeURIComponent() on your values. And yes, the server usually decodes the variables, but you can easily test that.

Felix
The correct function is `encodeURIComponent()`
Andy E
You're right, sorry, fixed it now.
Felix
+2  A: 

Use encodeURIComponent(string); And yes, the values are already decoded for you. Check out this article: http://www.hanselman.com/blog/CommentView.aspx?guid=d5756ece-8c33-4edd-80a7-f403e5fd6a07

einarq