views:

30

answers:

2

Why?

Server.UrlEncode("2*")

return 2*

while it should return 2%2A

as tested on this demo site

A: 

According to .NET, * is a 'safe' character and needs not to be encoded.

Whether this is actually correct or not, I do not know.

leppie
if it is safe then when i browse it...works Finehttp://localhost:2008/PinchofblissWeb/search/name=2but it doesn't browsehttp://localhost:2008/PinchofblissWeb/search/name=2*
SOF User
+2  A: 

RFC 1738 specifically allows * in the URL:

Thus, only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL.

So, there is no need to encode it.

The page you link to is a classic asp page so uses UrlEncode, so quite an old implementation and not the .NET one.

Oded
if it is safe then when i browse it... works Fine localhost:2008/PinchofblissWeb/search/name=2 but it doesn't browse localhost:2008/PinchofblissWeb/search/name=2*
SOF User
@SOF User - I have tried passing in `2*` as a regular parameter (`?name=2*`) without a problem. You are probably hitting something in a redirect engine.
Oded