wcf service HttpClient encode url with quotes

0

I need to send a parameter that includes the "[" character to a WCF service. Although I first encode the parameter, when I look at the detail of the url, the character encoding "[" has disappeared. Any idea what it can be?

string parameter = System.Net.WebUtility.UrlEncode("naFwi@dipSoKSws[sdoO");
var httpClient = new HttpClient(new NativeMessageHandler());
httpClient.BaseAddress = new Uri("http://127.0.0.1:8080/");
var response = await httpClient.GetAsync(string.Format("Service.svc/function/{0}", parameter));
    
asked by Jose 29.10.2016 в 13:47
source

1 answer

0

If you want to "escape" from a URI as I see it is your case you can use Uri.EscapeUriString

Example:

string parameter = "naFwi@dipSoKSws[sdoO";
string url = string.Format("Service.svc/function/{0}", parameter);
var response = await httpClient.GetAsync(System.Uri.EscapeUriString(url));
    
answered by 02.01.2017 в 02:22