Windows phone 8 下载韩国文件名的文件或文件损坏时收到的C#Box API[net_WebHeaderInvalidControlChars]

Windows phone 8 下载韩国文件名的文件或文件损坏时收到的C#Box API[net_WebHeaderInvalidControlChars],windows-phone-8,windows-phone-8.1,box-api,box,boxapiv2,Windows Phone 8,Windows Phone 8.1,Box Api,Box,Boxapiv2,从Box server下载时,我收到以下错误: InnerException {System.ArgumentException: [net_WebHeaderInvalidControlChars] Arguments: Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See

从Box server下载时,我收到以下错误:

    InnerException  {System.ArgumentException: [net_WebHeaderInvalidControlChars]
Arguments: 
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.7.60408.0&File=System.Net.dll&Key=net_WebHeaderInvalidControlChars
Parameter name: name
   at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClasse.<EndGetResponse>b__d(Object sendState)
   at System.Net.Browser.AsyncHelper.<>c__DisplayClass1.<BeginOnUI>b__0(Object sendState)}  System.Exception {System.ArgumentException}

请注意,这仅适用于具有韩语(非英语)文件名和损坏文件的文件。对于图像文件和未损坏的文件,我能够成功下载。(损坏文件的示例是打开时显示错误消息的word或ppt文件)。

在windows phone 8中存在相同问题。 我试过了 HttpResponseMessage response=等待httpClient.SendAsync(requestMessage)

我试过了 WebClient客户端=新的WebClient(); OpenReadAsync(新Uri(url,UriKind.RelativeOrAbsolute))

我试着回复RestClient

所有这些都会导致具有空值的异常和内部异常net\u WebHeaderInvalidControlChars

问题是服务器端无法识别从windows客户端传递的用户代理。结果,返回的响应头中的一个使.Net在较低级别崩溃,因此无法处理响应

添加NativeHost作为已识别的用户代理修复了异常

using (HttpClient client = new HttpClient(handler) { MaxResponseContentBufferSize = Int32.MaxValue })
{
    client.DefaultRequestHeaders.Add("Authorization", "Bearer " + accessToken);

    try
    {
        var fileResponse = await client.GetAsync(requestUrl, HttpCompletionOption.ResponseHeadersRead);                    

        if (fileResponse != null && fileResponse.StatusCode == System.Net.HttpStatusCode.OK)
            return await fileResponse.Content.ReadAsByteArrayAsync();
        else return null;
    }
    catch(Exception e)
    {
        System.Diagnostics.Debug.WriteLine("Error in getAsync, " + e.StackTrace);                    
        return null;
    }

}