错误StatusCode:500,ReasonPhrase:Web API发布大文件中的“内部服务器错误”

时间:2017-05-02 10:26:12

标签: post asp.net-web-api

我尝试通过web api发布请求。我有一个包含图像字段的类。

我的代码:

public bool SendRequest(FaxBranchRecive faxBranchRecive)
{
     using (var client = new HttpClient())
     {
        int fileLength = faxBranchRecive.faxImage.Length;
        // fileLength = 3873396
        var response = client.PostAsJsonAsync("http://localhost:58000/api/FaxBranch/RecieveFax", faxBranchRecive).Result;
          if (response.IsSuccessStatusCode)
          {                                    
               return true;
          }
          else
          {
               return false;
          }

       }
}

发布时显示此错误: enter image description here

{
    StatusCode: 500, 
    ReasonPhrase: 'Internal Server Error', 
    Version: 1.1, 
    Content: System.Net.Http.StreamContent, 
    Headers:
    {
        Cache-Control: private
        Server: Microsoft-IIS/8.0
        X-SourceFiles: =?UTF-8?B?RDpcVE9QRmF4XEZheENvbGxlY3Rpb25cUG9ydGFsRmF4TW9uaXRvcmluZ1xhcGlcRmF4QnJhbmNoXFJlY2lldmVGYXg=?=
        X-Powered-By: TOP
        X-Content-Type-Options: nosniff
        Date: Tue, 02 May 2017 10:07:45 GMT
        Content-Length: 4549
        Content-Type: text/html; charset=utf-8
    }
}

是否需要在服务器中发布大文件的配置?

0 个答案:

没有答案