我遇到了第一次机会例外:
System.ArgumentException: ''' is not a supported encoding name.
For information on defining a custom encoding,
see the documentation for the Encoding.RegisterProvider method.
Parameter name: name'
使用此代码
var request = new RestRequest(Method.GET);
request.AddParameter("subscription-key", API_KEY);
request.AddParameter("api-version", 1.0);
request.AddParameter("query", address.GetGeoCodeAddress());
IRestResponse response = null;
try { response = await client.ExecuteTaskAsync(request); }
catch (Exception ex){ }
答案 0 :(得分:0)
服务器可能未在响应标头中返回Content-Encoding
或不支持指定的编码。 RestSharp当前在try-catch块中处理此事件,从而导致First Chance Exception。但是,只要未指定Content-Encoding
,RestSharp应该默认为UTF8。
查看评论:https://github.com/restsharp/RestSharp/issues/867?_pjax=%23js-repo-pjax-container