c# - ASP.NET Vnext GZiped Body Post -
so i'm struggling little bit, can't quite wrap head around it. i've got asp.net vnext application that's hosting mvc , webapi-style controllers. controller in question looks this:
[httppost] public void post([fromquery] string json, [frombody]string item) { var requestbody = httpcontext.request.body; var posteddata = json.jsontodictionary(); var deviceserialnumber = posteddata["deviceserialnumber"].tostring(); datetime? endedat = posteddata["endedat"] == null ? (datetime?)null : datetime.parse(posteddata["endedat"].tostring()); //var controlreference = // _context.controls.firstordefault( // ctrl => ctrl.serialnumber == posteddata["deviceserialnumber"].tostring()) ?? new control() // { // }; }
my post data query string appropriate parameters seen in [fromquery] section. asp.net binding picks , can bind correctly , "json" parameter of method gets value.
however, body of post coming application outside of control. body of post gzip compressed, , can't bind of items [frombody] until asp.net unzips body. vnext apps don't apparently.
in previous applications use this:
globalconfiguration.configuration.messagehandlers.insert(0, new servercompressionhandler( new gzipcompressor(), new deflatecompressor()));
i don't believe works in vnext applications though.
what else i've tried is: modify applicationhosts file include following lines:
<urlcompression dodynamiccompression="true" /> <httpcompression> <dynamictypes> <add mimetype="application/json" enabled="true" /> <add mimetype="application/json; charset=utf-8" enabled="true" /> </dynamictypes> </httpcompression>
which hasn't had affect can tell. can see post coming in on wireshark , it's able decode json in body of message without issue, .net 4.0 app decode same message , bind [frombody] attribute once globalfilter line in.
any advice? i've found references response, in request body of post.
thanks!
Comments
Post a Comment