I totally understand that HTTP world is not the best choice for one-way calls and that WebApi is designed best for HTTP verbose communications. No doubt, WCF is the winner here. But, what if you already have an ApiController with a bunch of verbs exposed and at some point you needed to have a single one-way call too? And you don't want to host/maintain another service (WCF) for that.
Task<HttpResponseMessage> response = client.PostAsJsonAsync<Log>("api/log", log)
If you don't handle the response then you've got something similar to fire-and-forget. Is this the only way in WebApi or there's another solution?
Why not just call like this and ignore the returned task?
client.PostAsJsonAsync<Log>("api/log", log);
I do this with all my calls and use a handler in the response pipeline to deal with responses if necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With