I have a class that inherits from ApiController. It has a Put-like method:
[PUT("user/{UserId}")] public HttpResponseMessage Put(string userId, PaymentRequest paymentRequest) {
The method works fine, as it is higher. Now I need to verify the signature of the method call, but here I ran into a problem. A signature is essentially a combination of the + url + body method. The method that I can get by calling Request.Method and the url that I can get by calling Request.RequestUri.ToString (), but I canβt grab the body since it was before , it was automatically deserialized into the PaymentRequest object using the infrastructure asp.net MVC4.
My first attempt: As I now understand Request.Content.ReadAsStringAsync (). The result does not return anything. This is because the content can only be read once.
My second attempt: I tried converting it to a JSON string.
var serializer = new JavaScriptSerializer(); var paymentRequestAsJson = serializer.Serialize(paymentRequest);
The problem is that the formatting is a little different from the main part of the signature. It has the same data, but a few more gaps.
I cannot change what the caller of my Put method does, since this is a third-party component. What should I do?
Halvard Aug 10 2018-12-12T00: 00Z
source share