我尝试从一侧使用HttpClient.PostAsJsonAsync发送大消息json(带图像),并尝试使用Microsoft.AspNet.Mvc version =“5.2.3”在Controller中获取数据.
当我发送小消息时,一切都很好.
移动代码详情:
private async Task<HttpResponseMessage> Method<TRequest>(string url,TRequest request,IEnumerable<keyvaluePair<string,string>> headers) { using (var client = new HttpClient(_httpclienthandlerFactory.CreateHandler())) { client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue { NoCache = true }; AddHeadersToClient(client,headers); var response = await client.PostAsJsonAsync(url,request); ...
另一方面:
public class MyController: Controller { [HttpPost] public ActionResult EmailBody(string siteShortName,string templateName,RequestAcceptType acceptType,[DynamicJson] dynamic model) { //Some logic return View(viewPath,model); } ...
当发送消息时,我得到了
Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
根据文章Can I set an unlimited length for maxJsonLength in web.config?我尝试用不同的方法解决问题:
>在web.config section中添加
>在控制器方法中尝试this code
>尝试在Global.asax中添加something like this
在所有情况下,我都有同样的问题.
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。