I feel like I am missing something obvious here. I have the following code that executes when a user submits a checkout form online:
Stream body = Request.InputStream;
Encoding encoding = Request.ContentEncoding;
StreamReader reader = new StreamReader(body, encoding);
string json = reader.ReadToEnd();
dynamic order = JObject.Parse(json);
This works great and it allows me to then easily reference all of the properties in the stream simply by referencing the order
object. (e.g. order.CustomerName
).
The Problem
My client has added the requirement that the user may upload a file such as a purchase order. I have added the code to upload the file without issue, but now the code block I posted above barfs if there is a file in the InputStream
. Specifically, the error is "Input string '------' is not a valid number" which is thrown here:
dynamic order = JObject.Parse(json);
So, I assume that I need to somehow isolate Request.Params
when there is a file in the InputStream
and then run that through the code block above, but I am having a hard time getting down that road.
Any pointers, hints, or advice is welcome. Thanks.