asp.net - Post error: Either BinaryRead, Form, Files, or InputStream was accessed before the internal storage -
any post in asp.net mvc generate error:
server error in '/' application. either binaryread, form, files, or inputstream accessed before internal storage filled caller of httprequest.getbufferedinputstream. description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code. exception details: system.invalidoperationexception: either binaryread, form, files, or inputstream accessed before internal storage filled caller of httprequest.getbufferedinputstream. source error: unhandled exception generated during execution of current web request. information regarding origin , location of exception can identified using exception stack trace below. stack trace: [invalidoperationexception: either binaryread, form, files, or inputstream accessed before internal storage filled caller of httprequest.getbufferedinputstream.] system.web.httprequest.getentirerawcontent() +12673515 system.web.httprequest.get_inputstream() +61 system.web.mvc.jsonvalueproviderfactory.getvalueprovider(controllercontext controllercontext) +132 system.web.mvc.<>c__displayclassc.<getvalueprovider>b__7(valueproviderfactory factory) +28 system.linq.whereselectenumerableiterator`2.movenext() +248 system.linq.whereselectenumerableiterator`2.movenext() +165 system.collections.generic.list`1..ctor(ienumerable`1 collection) +536 system.linq.enumerable.tolist(ienumerable`1 source) +80 system.web.mvc.valueproviderfactorycollection.getvalueprovider(controllercontext controllercontext) +343 system.web.mvc.controllerbase.get_valueprovider() +57 system.web.mvc.controlleractioninvoker.getparametervalue(controllercontext controllercontext, parameterdescriptor parameterdescriptor) +81 system.web.mvc.controlleractioninvoker.getparametervalues(controllercontext controllercontext, actiondescriptor actiondescriptor) +153 system.web.mvc.async.<>c__displayclass25.<begininvokeaction>b__1e(asynccallback asynccallback, object asyncstate) +839919 system.web.mvc.async.wrappedasyncresult`1.begin(asynccallback callback, object state, int32 timeout) +146 system.web.mvc.async.asyncresultwrapper.begin(asynccallback callback, object state, begininvokedelegate begindelegate, endinvokedelegate`1 enddelegate, object tag, int32 timeout) +166 system.web.mvc.async.asyncresultwrapper.begin(asynccallback callback, object state, begininvokedelegate begindelegate, endinvokedelegate`1 enddelegate, object tag) +27 system.web.mvc.<>c__displayclass1d.<beginexecutecore>b__17(asynccallback asynccallback, object asyncstate) +50 system.web.mvc.async.wrappedasyncresult`1.begin(asynccallback callback, object state, int32 timeout) +146 system.web.mvc.async.asyncresultwrapper.begin(asynccallback callback, object state, begininvokedelegate begindelegate, endinvokedelegate`1 enddelegate, object tag, int32 timeout) +166 system.web.mvc.controller.beginexecutecore(asynccallback callback, object state) +827009 system.web.mvc.async.wrappedasyncresult`1.begin(asynccallback callback, object state, int32 timeout) +146 system.web.mvc.async.asyncresultwrapper.begin(asynccallback callback, object state, begininvokedelegate begindelegate, endinvokedelegate`1 enddelegate, object tag, int32 timeout) +166 system.web.mvc.async.asyncresultwrapper.begin(asynccallback callback, object state, begininvokedelegate begindelegate, endinvokedelegate enddelegate, object tag) +27 system.web.mvc.controller.beginexecute(requestcontext requestcontext, asynccallback callback, object state) +401 system.web.mvc.<>c__displayclass8.<beginprocessrequest>b__2(asynccallback asynccallback, object asyncstate) +787114 system.web.mvc.async.wrappedasyncresult`1.begin(asynccallback callback, object state, int32 timeout) +146 system.web.mvc.async.asyncresultwrapper.begin(asynccallback callback, object state, begininvokedelegate begindelegate, endinvokedelegate`1 enddelegate, object tag, int32 timeout) +166 system.web.mvc.async.asyncresultwrapper.begin(asynccallback callback, object state, begininvokedelegate begindelegate, endinvokedelegate enddelegate, object tag) +27 system.web.mvc.mvchandler.beginprocessrequest(httpcontextbase httpcontext, asynccallback callback, object state) +343 system.web.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() +12622419 system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +288 version information: microsoft .net framework version:4.0.30319; asp.net version:4.0.30319.18213
full error details:
system.invalidoperationexception either binaryread, form, files, or inputstream accessed before internal storage filled caller of httprequest.getbufferedinputstream. system.invalidoperationexception: either binaryread, form, files, or inputstream accessed before internal storage filled caller of httprequest.getbufferedinputstream. @ system.web.httprequest.getentirerawcontent() @ system.web.httprequest.get_inputstream() @ system.web.httprequestwrapper.get_inputstream() @ system.web.mvc.jsonvalueproviderfactory.getdeserializedobject(controllercontext controllercontext) @ system.web.mvc.jsonvalueproviderfactory.getvalueprovider(controllercontext controllercontext) @ castle.proxies.invocations.valueproviderfactory_getvalueprovider.invokemethodontarget() @ castle.dynamicproxy.abstractinvocation.proceed() @ glimpse.core.extensibility.castleinvocationtoalternatemethodcontextadapter.proceed() @ glimpse.core.extensions.alternatemethodcontextextensions.tryproceedwithtimer(ialternatemethodcontext context, timerresult& timerresult) @ glimpse.core.extensibility.alternatemethod.newimplementation(ialternatemethodcontext context) @ glimpse.core.extensibility.alternatetypetocastleinterceptoradapter.intercept(iinvocation invocation) @ castle.dynamicproxy.abstractinvocation.proceed() @ castle.proxies.valueproviderfactoryproxy.getvalueprovider(controllercontext controllercontext) @ system.web.mvc.valueproviderfactorycollection.<>c__displayclassc.<getvalueprovider>b__7(valueproviderfactory factory) @ system.linq.enumerable.whereselectenumerableiterator`2.movenext() @ system.linq.enumerable.whereselectenumerableiterator`2.movenext() @ system.collections.generic.list`1..ctor(ienumerable`1 collection) @ system.linq.enumerable.tolist[tsource](ienumerable`1 source) @ system.web.mvc.valueproviderfactorycollection.getvalueprovider(controllercontext controllercontext) @ system.web.mvc.controllerbase.get_valueprovider() @ system.web.mvc.controlleractioninvoker.getparametervalue(controllercontext controllercontext, parameterdescriptor parameterdescriptor) @ system.web.mvc.controlleractioninvoker.getparametervalues(controllercontext controllercontext, actiondescriptor actiondescriptor) @ system.web.mvc.async.asynccontrolleractioninvoker.<>c__displayclass25.<begininvokeaction>b__1e(asynccallback asynccallback, object asyncstate) @ system.web.mvc.async.asyncresultwrapper.wrappedasyncresult`1.begin(asynccallback callback, object state, int32 timeout) @ system.web.mvc.async.asynccontrolleractioninvoker.begininvokeaction(controllercontext controllercontext, string actionname, asynccallback callback, object state) @ system.web.mvc.controller.<>c__displayclass1d.<beginexecutecore>b__17(asynccallback asynccallback, object asyncstate) @ system.web.mvc.async.asyncresultwrapper.wrappedasyncresult`1.begin(asynccallback callback, object state, int32 timeout) @ system.web.mvc.controller.beginexecutecore(asynccallback callback, object state) @ system.web.mvc.async.asyncresultwrapper.wrappedasyncresult`1.begin(asynccallback callback, object state, int32 timeout) @ system.web.mvc.controller.beginexecute(requestcontext requestcontext, asynccallback callback, object state) @ system.web.mvc.controller.system.web.mvc.async.iasynccontroller.beginexecute(requestcontext requestcontext, asynccallback callback, object state) @ system.web.mvc.mvchandler.<>c__displayclass8.<beginprocessrequest>b__2(asynccallback asynccallback, object asyncstate) @ system.web.mvc.async.asyncresultwrapper.wrappedasyncresult`1.begin(asynccallback callback, object state, int32 timeout) @ system.web.mvc.mvchandler.beginprocessrequest(httpcontextbase httpcontext, asynccallback callback, object state) @ system.web.mvc.mvchandler.beginprocessrequest(httpcontext httpcontext, asynccallback callback, object state) @ system.web.mvc.mvchandler.system.web.ihttpasynchandler.beginprocessrequest(httpcontext context, asynccallback cb, object extradata) @ system.web.httpapplication.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() @ system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously)
route config:
default
public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional }, namespaces: new string[] { "creditoimobiliariobb.web.controllers" } ); }
areas
public override void registerarea(arearegistrationcontext context) { context.maproute( "usuario_default" ,"usuario/{controller}/{action}/{id}" ,new { controller="home", action = "index", id = urlparameter.optional } , namespaces: new string[] { "creditoimobiliariobb.web.areas.usuario.controllers" } ); } public override void registerarea(arearegistrationcontext context) { context.maproute( name: "relatorios", url: "{controller}/{id}/relatorio/{action}", defaults: new { id = 1 }, constraints: new { id = @"^\d+$" }, namespaces: new string[] { "creditoimobiliariobb.web.areas.relatorios" } ); } public override void registerarea(arearegistrationcontext context) { context.maproute( name: "documentos", url: "{controller}/{id}/documento/{action}", defaults: null, constraints: new { id = @"^\d+$" } ); }
just posting findings here - summary of chat - since others may error. don't hand out bounty, since didn't find solution. ;-)
the error result of trying access binaryread
, form
, files
or inputstream
after else has accessed request entity body stream (in other words, content of request) using different method.
these "different methods" seem include getbufferedinputstream
, getbufferlessinputstream
. these methods appear (not sure) mutually exclusive. in other words, single request, can use 1 of:
binaryread()
,form
,files
,inputstream
(these "cooperate" each other),getbufferedinputstream()
, orgetbufferlessinputstream()
getbufferedinputstream
should cooperate "classic" access methods, according documentation - in fact, that's difference getbufferlessinputstream
. nonetheless, in case, error stems getbufferedinputstream()
being used, followed inputstream
.
the different methods (inadequately) described in documentation readentitybodymode property , its enum type.
a recent commit asp.net webapi changed method of reading body entity getbufferedinputstream()
before used request.inputstream
.
this appears conflict mvc's jsonvalueproviderfactory.getdeserializedobject
uses "classic" inputstream
property read entity body. if take error message @ face value, getbufferedinputstream()
has been called, isn't done reading when inputstream
accessed, inputstream
hasn't been filled yet.
need more testing, temporary fix (found @kiranchalla) revert build before above-mentioned commit.
Comments
Post a Comment