I'm developing an ASP.Net WebAPI service to allow embedded devices to transfer data in semi-realtime.
These devices will be on a capped wireless broadband plan, which means that low data consumption usage is a requirement for this project.
The devices will send data through HTTP in JSON format. At the moment, I include "Content-Type: application/json" in the header, which works well.
However, I'm thinking it is a waste of precious bytes (and data usage plan) to send these few bytes over the wire everytime. I can be 100% sure, at the moment that the data sent will be encoded by JSON, so I would rather have the server assume the Content-Type when it is missing.
However, if I omit it, my Post controllers do no trigger anymore when the client posts to them. They are declared like that:
public HttpResponseMessage Post([FromBody] MyEvent myEvent)
In short, what I'm trying to do is to automatically add, on the server-side, the Content-Type to the incoming HTTP requests that the client would have omitted to add, or another way of making my controllers work and automatically deserialize the JSON message, even with that Content-Type header entry is missing.
I'm hoping there might be a source code file or configuration on the WebAPI project where I could configure that?
Thanks in advance.