繁体   English   中英

当我尝试将json发布到webservice时出现错误500

[英]I got error 500 when I try to post a json to webservice

我正在开发c#Windows形式的应用程序,当我尝试发送大型json时,出现异常erro 500。

在此处输入图片说明

POST的方法

public void POST(string url, string jsonContent)
{
    HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
    request.Method = "POST";

    System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
    Byte[] byteArray = encoding.GetBytes(jsonContent);

    request.ContentLength = byteArray.Length;
    request.ContentType = "application/json";


    using(Stream dataStream = request.GetRequestStream())
    {
        dataStream.Write(byteArray, 0, byteArray.Length);
    }
    long length = 0;
    try
    {
        using(HttpWebResponse response = (HttpWebResponse) request.GetResponse())
        {
            length = response.ContentLength;
        }
    }
    catch (WebException ex)
    {

        // Log exception and throw as for GET example above
    }
}

我可以使用JSON发送其他对象,但是特别是具有大量数据的该对象,我得到此异常。 但是,当我尝试从Web服务中获取该对象时,它工作得很好。

问题是,我可以获得大量数据,但无法发送相同的数据。

按照我的控制器的代码。

[Route("reconhecimento")]
[HttpPost]
    public bool PostPessoasReconhecimento([FromBody]PessoaReconhecimentoModel[] newpessoaReconhecimento)
    {

    PessoaReconhecimentoModel pessoaReconhecimento = new PessoaReconhecimentoModel();
        return pessoaReconhecimento.postPessoaReconhecimento(newpessoaReconhecimento);
    }

Joab我想问题可能与您的要求有关。

尝试检查是否将您的问题归类为该问题的重复项: IIS 7的最大默认POST请求大小-如何增加64kB / 65kB的限制?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM