Skip to content

Instantly share code, notes, and snippets.

@justingarrick
Last active December 21, 2015 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justingarrick/6343093 to your computer and use it in GitHub Desktop.
Save justingarrick/6343093 to your computer and use it in GitHub Desktop.
Read raw JSON in a WebAPI method that uses model binding
//Add
//Request.Content.ReadAsStreamAsync().ContinueWith(t => t.Result.Seek(0, SeekOrigin.Begin)).Wait();
//to your POST method, e.g.
[AntiForgeryToken]
public WeldProjectInfo Post([FromBody]RequestDetail details)
{
try
{
Request.Content.ReadAsStreamAsync().ContinueWith(t => t.Result.Seek(0, SeekOrigin.Begin)).Wait();
WeldProjectInfo weldProjectInfo = new WeldProjectInfo();
//...
}
}
//Step over the origin seek line, then add a watch for
//Request.Content.ReadAsStringAsync().Result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment