Read raw request body in asp.net core MVC -




i need process raw request body in , mvc core controller has route parameters

[httpput] [route("api/foo/{fooid}")] public async task put(string fooid) {    reader.read(request.body).tolist();    await _store.add("tm", "test", data); } 

but seems model binder has consumed request stream time gets controller.

if remove route parameters, can access request stream (since framework no longer process stream parameters). how can specify both route parameters , able access request body without having manually parse request uri etc.?

i have tried decorating parameters [fromroute] had no effect.

  • please note cannot bind request body object , have framework handle binding, expecting extremely large payload needs processed in chunks in custom manner.
  • there no other controller, no custom middle-ware, filters, serialzier, etc.
  • i not need process body several times, once
  • storing stream in temp memory or file stream not options, want process request body directly.

how can framework bind paramters uri, querystring, etc. leave request body me?

as suspected root cause mvc inspecting request body in order try bind route parameters. how model binding works default routes not parameter-less, per documentation.

the framework when request content type not specified, or when form data (multipart or url-encoded assume).

changing request content-type thing other form data (e.g. application/json) can framework ignore body unless required (e.g. [frombody] route parameter). acceptable solution case since interested accepting json payloads content-type application/json.

implementation of disableformvaluemodelbindingattribute in uploading large files streaming pointed out @tseng seems better approach however, using instead, complete





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -