0

When a request to my action gets called.. it sometimes works fine and in other cases shows Message='Cancelled'.

While checking trace messages in Azure application insights, the following is what I found..

The successful as well as unsuccessful requests went through create controller, select controller and select action.

After that the unsuccessful ones start giving Message='Cancelled' in FormatterParameterBinding.ExecuteBindingAsync, DefaultController.ExecuteAsync, HttpActionBinding.ExecuteBindingAsync.

Unlike the above, the successful ones show Message='Model state is valid in HttpActionBinding.ExecuteBindingAsync and InvokeActionAsync with Status 200(OK).

At first I thought that perhaps the data sent is not matching the model of action parameter but that is highly unlikely as we keep the data from client in localstorage and from there send it to the server, unless we receive status 200 from te call to server, we do not remove the data but send the previous data along with the new one next time. If the data did not match the model then in my view it will not match even the next time but here a call with certain data shows cancelled and later with the same data and more it shows success.

Can anyone with knowledge of webapi2 internals understand what the problem could be in this case.

Any help is sincerely appreciated.

Arnab
  • 2,324
  • 6
  • 36
  • 60

1 Answers1

0

It would be a good idea to implement an IHttpModule to log requests (what you are actually receiving in the backend), and then correlate with your ApplicationInsight error. Without knowing that it's super hard to track / fix your problem.

Thiago Custodio
  • 17,332
  • 6
  • 45
  • 90
  • I'm not very famiiar with HttpModule but could do the same using DelegatingHandler as http://stackoverflow.com/questions/12300458/web-api-audit-logging I see they are getting the model using request.content will this provide what I'm receiving in case of Get and well as Post. Also they are overriding SendAsync, which happens a lot later than FormatterParameterBinding.ExecuteBindingAsync, any ideas?? – Arnab Sep 21 '16 at 05:53
  • You're right, it's the same idea of this one with DelegatingHandler. So, now you should track your logs and find an error. Then, you will try to figure out (correlate), what was the request for that particular error. – Thiago Custodio Sep 21 '16 at 20:51
  • The async thing is just to avoid blocking on your main thread. Just be sure to use the Wait fix http://stackoverflow.com/a/16201056/1384539 – Thiago Custodio Sep 21 '16 at 20:53
  • PS: After you identify the request that is causing the error, update your question and I'll try to help. Ps2: remove this DelegatingHandler later – Thiago Custodio Sep 21 '16 at 20:54