Bug 18050 - WebAPI requests throw a NullReferenceException when calling DelegatingHandler.InnerHandler.SendAsync
Summary: WebAPI requests throw a NullReferenceException when calling DelegatingHandler...
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web ()
Version: 3.2.x
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-02-27 08:30 UTC by Arne Ruhnau
Modified: 2014-05-14 10:46 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Launches a self-hosted WebAPI in OWIN that throws on every request (925.15 KB, application/x-zip-compressed)
2014-02-27 08:30 UTC, Arne Ruhnau

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Arne Ruhnau 2014-02-27 08:30:59 UTC
Created attachment 6172 [details]
Launches a self-hosted WebAPI in OWIN that throws on every request

This is a follow-up bug to bug 17965. After patching in support for an anonymous user into the Microsoft.Owin.Host.HttpListener I reproducibly get a NullReferenceException for every HTTP request when calling DelegatingHandler.InnerHandler.SendAsync.

As with case 17965, as soon as I unplug WebAPI from the OWIN pipeline, everything works correctly.

Find attached a program to reproduce this issue. The program serves to URIs:
http://localhost:12345/ -> handled by Nancy. Works when WebAPI is not plugged into the pipeline
http://localhost:12345/api/some -> handled by WebAPI

The Microsoft.Owin.Host.HttpListener included is a private build with the workaround for bug 17965 included.
Comment 1 Arne Ruhnau 2014-05-14 10:46:53 UTC
I revisited this on a custom build of mono from master/a8f3f77 under Ubuntu 14.04 and could no longer reproduce what I saw in the windows build. Since I'm aiming for linux and as-recent-as-possible mono, it works for me.