C# 文件上载在Win phone 8上不起作用

C# 文件上载在Win phone 8上不起作用,c#,windows-phone-8,upload,dotnet-httpclient,C#,Windows Phone 8,Upload,Dotnet Httpclient,我有一个用户可以录制视频的应用程序和一个将录制的视频上传到azure的api。 我正在使用下面的代码 HttpClientHandler handler = new HttpClientHandler(); handler.MaxRequestContentBufferSize = int.MaxValue; using (HttpClient httpClient = new HttpClient(handler) { MaxResponseConte

我有一个用户可以录制视频的应用程序和一个将录制的视频上传到azure的api。 我正在使用下面的代码

HttpClientHandler handler = new HttpClientHandler();
handler.MaxRequestContentBufferSize = int.MaxValue;
using (HttpClient httpClient = new HttpClient(handler) 
       { 
            MaxResponseContentBufferSize = int.MaxValue
       })
{
    MultipartFormDataContent content = new MultipartFormDataContent();
    content.Add(new ByteArrayContent(chunks), "file", fileName);
    HttpResponseMessage response = null;
    response = await httpClient.PostAsync(new Uri(url), content);
    return await response.Content.ReadAsStringAsync();
}
仅当视频小于10秒时,此功能才起作用。当我试图上传20-30MB大小的视频时,它失败了。 作为回应,我得到了状态码404

我还尝试了另一种上传方式。但结果是相同的错误:

string boundary = Guid.NewGuid().ToString();

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "POST";
        request.ContentType = "multipart/form-data;boundary=" + boundary;

        StringBuilder header = new StringBuilder();
        header.Append("\r\n--");
        header.Append(boundary);
        header.Append("\r\n");
        header.Append("Content-Disposition: file; name=\"file\"; filename=\"" + fileName + "\"\r\n");
        header.Append("Content-Type: application/octet-stream\r\n\r\n");
        byte[] headerbytes = Encoding.UTF8.GetBytes(header.ToString());

        StringBuilder footer = new StringBuilder();
        footer.Append("\r\n--");
        footer.Append(boundary);
        footer.Append("--\r\n");
        byte[] footerbytes = Encoding.UTF8.GetBytes(footer.ToString());

        using (var streamWriter = await request.GetRequestStreamAsync())
        {
            streamWriter.Write(headerbytes, 0, headerbytes.Length);              
            streamWriter.Write(footerbytes, 0, footerbytes.Length);
            streamWriter.Flush();
        }

        var httpResponse = (HttpWebResponse)await request.GetResponseAsync();
        using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
        {
            return streamReader.ReadToEnd();                
        }

检查web.api站点的web.config,特别是本节

<configuration>
  <system.web>
    <httpRuntime maxRequestLength="xxx" />
  </system.web>
</configuration>


xxx的单位是KB。

我刚从api开发者那里确认过,他说最大长度限制为60MB。但在我的例子中,即使有30 MB,我也会出错。@mayank.karki,您能在WP和iOS/Android上使用Burp/fiddler捕获请求并发布标题以进行比较吗?