I have a C# API using OWIN.
In one of my OwinMiddleware components I read some properties off context.Request after the Controller processes the request, and sometimes this blows up with an "Object is already disposed" error from the HttpListenerRequest deep inside the IOwinRequest.
So, something is triggering that disposal. I believe this is a bug, because according to this question that shouldn't happen.
So I need to work out what is causing that disposal ... but I can't because I have no idea when it's ocurring (other than "before this point").
Ideally, I want to do something that causes the debugger to stop at some point closely related to when the disposal happens.
Things I've tried and which haven't worked:
I can get Rider to decompile some obvious bits of the .NET code, but Breakpoints set in there don't hit.
I can replace the
context.Requestwith a wrapped version of itself, and so I thought that I could track the Dispose call on theOwinRequestdown through the layers ... except the Request object isn'tIDisposable, and I can't see any other obvious way that theOwinRequestis in control of when the internal disposal happens.I can't find a seam to be able to get at where the inner object gets set up - it looks like WebApi does that for me somewhere that I can't reach.