asp.net web service maximum json input length has been exceeded -
i got webserver in .net working nancyfx. have route has upload image, image sent client in json byte64 encoded, along other attributes. when seek bind incoming json model, got next exception: "maximum json input length has been exceeded."
something this:
post["/upload", true] = async(_, ctx) => { uploadmodel model = null; model = this.bind<uploadmodel >(); . . . } i've read changing value of "maxjsonlength" in web.config handles issue, when set higher value it, there's no effect:
<scripting> <webservices> <jsonserialization maxjsonlength="50000000"/> </webservices> </scripting> along maxrequestlength:
<httpruntime targetframework="4.5" maxrequestlength="1000000"/> for smaller pictures (5kb, 50kb) there's no problem in binding, when send pictures sizes of 144kb , up, gives me error in concern.
any thoughts? if missed relevant information, inquire me
never mind guys, found answer:
in nancy documentation says "if encounter nancy.json.jsonsettings.maxjsonlength exceeded error because payload high, alter limit in bootsrapper ..."
so did it:
public class bootstrapper : defaultnancybootstrapper { protected override void applicationstartup(nancy.tinyioc.tinyioccontainer container, nancy.bootstrapper.ipipelines pipelines) { base.applicationstartup(container, pipelines); nancy.json.jsonsettings.maxjsonlength = int.maxvalue; } } now, no more maxjsonlength errors, hope helps in future!
asp.net json nancy
No comments:
Post a Comment