Error in C# APS.NET web project with both MVC and WebApi
KU
Posted on
Feb 27 2015
Hi there,
We are using Raygun on an ASP.NET web project that consists of both MVC and WebApi. We are also using OWIN for integrating the webapi pipeline as our web services are secured by OAUTH. This means we use the app.UseWebApi() in the Owin startup class.
We have configured Raygun on both the MVC and the WebApi pipeline as described in the Raygun documentation.
The problem occurs when trying to access an MVC controller action that has one or more parameters. In this case the request fails with a "This method or property is not supported after HttpRequest.GetBufferlessInputStream has been invoked." exception.
After looking at the Raygun sourcecode I have found that when WebApi is used together with Owin the RaygunWebApiDelegatingHandler is called for MVC controllers as well - this is not the case when Raygun WebApi is configured like normal in the global.asax.
I have made a POC project showing the problem - which can be downloaded here:
https://drive.google.com/file/d/0BwaBDWc05M-UN1ZlOS1jWVh6SEE/view?usp=sharing
In Global.asax, Startup.cs and WebApiConfig there are some comments describing the problem and how to reproduce it.
Jason Fauchelle
Raygun
Posted on
Feb 27 2015
Hi KU,
Thanks for contacting us about this and providing a repro project. We'll look into this and get back to you with what we find.
-Jason Fauchelle
Jason Fauchelle
Raygun
Posted on
Mar 10 2015
Hi KU,
Thanks again for the repro project. We've just released Raygun4Net version 5.0 which includes a candidate fix for this. This fix solves the problem in your repro project, but has the downside of not including the request payload in the exception report when Owin is present. Reading the request payload is what was causing the problem.
Let us know if this solves the issue for you.
-Jason Fauchelle
Christian Johansen
Posted on
Apr 15 2016
Well We have the same issue at Planday. We would really like to see the request payload. And we use OWIN. Any chance this might be fixed? Any work arounds ? BR Christian Johansen
Christian Johansen
Posted on
Apr 15 2016
--
Jason Fauchelle
Raygun
Posted on
Apr 18 2016
Hi Christian,
The stream for reading the OWIN request body is not rewindable, so if Raygun reads it, model bindings don't work as the request payload can't be read again.
I've noted down to look at if this is still a problem or if we could find a solution for a future Raygun4Net version.
-Jason Fauchelle
inbox007
Posted on
Jul 30 2020
This issue is still occurring (raygun4net.mvc - 5.10.3) and (.Raygun4Net.WebApi - 5.10.3), project is .net framework 4.8
What is the suggested workaround?
Deleted User
Raygun
Posted on
Jul 31 2020
Hi inbox007,
Thank you for getting in touch. We currently have a work around that disables the capturing of the raw request body. The following snippet can be used to stop the Raygun client from attempting to capture the raw request payload.
RaygunSettings.Settings.IsRawDataIgnored = true
I will raise this issue again with the wider team for us to investigate. I do not have a time frame for when this issue will be picked up but we will notify this thread once this occurs.
Thank you, Mitchell.
inbox007
Posted on
Jul 31 2020
Hey Mitchell,
Thanks for the speedy response! That works OK for now as not having the payload isn't a showstopper for us.
Regards
Phil
Deleted User
Raygun
Posted on
Aug 02 2020
Hi Phil,
No problem at all, we will update this thread when we have an update.
Regards, Mitchell.