Thursday, March 22, 2012

Maintaining URL encoding for comman (",")

I am passing URL encoded value in query string and then on server side I
process this query string. There is one situation that is bugging me. The
value from client side can contain "," (commas) and I URL encode the value
and then explictly replace "," with "%2C". So far so good. But when i
retrive this QS param value, "%2C" has already been replaced with ",".

Client side brings the use to the page by setting path on window.location as
follows:

window.location.href= "http://mysite.com?a=1&b=foo%2cbar%2cbaz

When it comes to server side, the QS param "b" is "foo,bar,baz".

How can i maintian the hex value for "," when it comes to server side.

ThanksN wrote:

Quote:

Originally Posted by

I am passing URL encoded value in query string and then on server side I
process this query string. There is one situation that is bugging me. The
value from client side can contain "," (commas) and I URL encode the value
and then explictly replace "," with "%2C". So far so good. But when i
retrive this QS param value, "%2C" has already been replaced with ",".
>
Client side brings the use to the page by setting path on window.location as
follows:
>
window.location.href= "http://mysite.com?a=1&b=foo%2cbar%2cbaz
>
When it comes to server side, the QS param "b" is "foo,bar,baz".
>
How can i maintian the hex value for "," when it comes to server side.
>
Thanks
>
>


why don t simply use :
window.location.href= Server.HTMLEncode(
"http://mysite.com?a=1&b=foo,bar,baz");

and after : Request["b"].ToString();
and in black case... Server.HTMLDecode( Request["b"].ToString() );

0 comments:

Post a Comment