介绍:
Web应用程序,ASP.NET MVC 3,一种控制器操作,它接受具有(可能)大字段的POCO模型类的实例.
型号类:
public class View
{
[Required]
[RegularExpression(...)]
public object name { get; set; }
public object details { get; set; }
public object content { get; set; } // the problem field
}
Run Code Online (Sandbox Code Playgroud)
控制器动作:
[ActionName(...)]
[Authorize(...)]
[HttpPost]
public ActionResult CreateView(View view)
{
if (!ModelState.IsValid) { return /*some ActionResult here*/;}
... //do other stuff, create object in db etc. return valid result
}
Run Code Online (Sandbox Code Playgroud)
问题:
一个动作应该能够接受大型JSON对象(在单个请求中至少高达100兆字节,这不是一个笑话).默认情况下,我遇到了几个限制httpRuntime maxRequestLength等等 - 除了MaxJsonLengh之外都解决了 - 这意味着JSON的默认ValueProviderFactory无法处理这些对象.
尝试:
设置
<system.web.extensions>
<scripting>
<webServices> …Run Code Online (Sandbox Code Playgroud)