The HttpUtility class has a static UrlEncode function. It does safely
encodes a url that includes spaces and symbols so that they are correctly
interpreted by the server. This is safer, more maintainable and less error
prone than doing a manual concatenation.
From MSDN:
"If characters such as blanks and punctuation are passed in an HTTP stream,
they might be misinterpreted at the receiving end. URL encoding converts
characters that are not allowed in a URL into character-entity equivalents;
URL decoding reverses the encoding. For example, when embedded in a block of
text to be transmitted in a URL, the characters < and > are encoded as %3c
and %3d"
Incidentally, in ASP.Net, the UrlEncode is also available via the Server
object.
A related function you might be interested in the HttpEncode - it ensures
that any symbols are converted into valid html and prevents jscript hacks.
As a generate rule I always use HttpEncode when returning generated content.
I hope that helps,
Arnd Hurlbrink
"beachboy" <st*****@javacatz.com> wrote in message
news:eF**************@TK2MSFTNGP11.phx.gbl...
I have a problem if the parameter has a "&" symbol in querystring,
i think asp.net will split the value into 2 values as "&" is a spliter
any advise can give me to solve this problem?
P.S. I can't restrict user don't input "&" symbol when input
Thanks in advanced.