c# - Encoding parameters for a URL -
i have silverlight application building url. url call rest-based service. service expects single parameter represents location. location in form of "city, state". build url, i'm calling following code:
string url = "http://www.domain.com/myservice.svc/"; url += httputility.urlencode(locationtextbox.text);
if user enters "chicago, il" locationtextbox, result looks this:
http://www.domain.com/myservice.svc/chicago%2c+il
in reality though, kind of expecting url like;
http://www.domain.com/myservice.svc/chicago,%20il
when testing service via browser url, 1 expecting works. however, url being generated not working. doing wrong?
i recommend uri.escapedatastring instead of using httputility functions. see discussion in server.urlencode vs. httputility.urlencode.
Comments
Post a Comment