












1. c# web项目使用集合形式的参数,接收不到参数出现如下错误时 "The JSON request was too large to be deserialized"。解决方案如下:
[HttpPost]
public async Task<JsonResult> ReceivemThirdPartyMatPrice()
{
// 获取请求体的原始 JSON 数据
string rawJson = await new System.IO.StreamReader(Request.InputStream).ReadToEndAsync();
// 使用 Newtonsoft.Json 来反序列化,并指定配置
var jsonSettings = new JsonSerializerSettings
{
MaxDepth = 3, // 可以增加最大深度
NullValueHandling = NullValueHandling.Ignore, // 忽略空值
DefaultValueHandling = DefaultValueHandling.Ignore,
Formatting = Formatting.Indented
};
// 反序列化 JSON 数据
var list = JsonConvert.DeserializeObject<List<ThirdPartyMatPrice>>(rawJson, jsonSettings);
//开始处理接收的list列表数据
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。