Json 将复杂类型发布到web api

Json 将复杂类型发布到web api,json,post,asp.net-web-api,complextype,Json,Post,Asp.net Web Api,Complextype,我试图将下面的复杂对象检查发布到web api httppost方法 public class Inspection { public string Url { get; set; } public int HireContractLineId { get; set; } public List<ImageInfo> Images { get; set; } } public class ImageInfo { public DateTime Capt

我试图将下面的复杂对象检查发布到web api httppost方法

public class Inspection
{
    public string Url { get; set; }
    public int HireContractLineId { get; set; }
    public List<ImageInfo> Images { get; set; }
}
public class ImageInfo
{
    public DateTime CapturedDateTime { get; set; }
    public string ImageData { get; set; }
    public string  FileName { get; set; }
    public string ContentType { get; set; }
}

您可以在web.config中更改允许的最大请求大小。找到该节并将maxRequestLength设置为所需的限制(KB)。例如,要将最大值设置为8MB,您需要编写:
。如果增加此最大请求长度,会发生什么情况?(作为记录,如果未指定maxRequestLength,Web API假定默认值为4 MB。如果某些图像大于200 KB,并且您使用base64编码来传输它们,您肯定会达到此限制)。@pymaxion,感谢您的回复,我已经尝试过了,我已经设置了,而且一开始我得到了最大大小达到异常,在这些配置更改后得到了修复,但发布的原始问题仍然存在。哎呀,我的错误是,我确实在客户端控制器中更改了请求长度,但实际的web api配置没有设置内容长度,因此,我将client配置文件和webapi配置文件都更改为add,现在可以工作了
[ActionName("Inspection")]
[HttpPost]
public HttpResponseMessage Post([FromBody]  Inspection inspection)
{
         List<ImageInfo> images = inspection.Images;
            for (var i = 0; i < images.Count; i++)
            {
            }
}
   client.BaseAddress = new Uri(AppParameters.WebApiBaseURL);
   HttpResponseMessage response =
                await client.PostAsJsonAsync("api/fleetitems/Inspection", inspection);