SDammann.WebApi.Versioning icon indicating copy to clipboard operation
SDammann.WebApi.Versioning copied to clipboard

ArgumentNullException when version header missing

Open richardp-au opened this issue 9 years ago • 0 comments

I updated to 3.0.0-beta3 to incorporate the new exception handling changes but I'm not getting an ArgumentNullException when the version header isn't supplied. My understanding was that I should expect an ApiVersionNotDeterminedException instead but it looks to me like it's not getting to the line that checks for that.

My API uses the Accept header for versioning so I have a class derived from AcceptHeaderRequestVersionDetector. This used to work fine in beta1 but upon upgrading it has stopped working. Everything appears to work fine when the version is supplied in the Accept header.

Here's the exception details and stack trace:

System.ArgumentNullException was unhandled by user code
  HResult=-2147467261
  Message=Value cannot be null.
Parameter name: version
  Source=SDammann.WebApi.Versioning
  ParamName=version
  StackTrace:
       at SDammann.WebApi.Versioning.ControllerIdentification..ctor(String name, ApiVersion version) in z:\Developing\Visual Studio\Projects\SDammann.WebApi.Versioning\src\SDammann.WebApi.Versioning\ControllerIdentification.cs:line 42
       at SDammann.WebApi.Versioning.Request.DefaultRequestControllerIdentificationDetector.GetIdentification(HttpRequestMessage requestMessage) in z:\Developing\Visual Studio\Projects\SDammann.WebApi.Versioning\src\SDammann.WebApi.Versioning\Request\DefaultRequestControllerIdentificationDetector.cs:line 43
       at SDammann.WebApi.Versioning.VersionedApiControllerSelector.GetControllerIdentificationFromRequest(HttpRequestMessage request) in z:\Developing\Visual Studio\Projects\SDammann.WebApi.Versioning\src\SDammann.WebApi.Versioning\VersionedApiControllerSelector.cs:line 105
       at SDammann.WebApi.Versioning.VersionedApiControllerSelector.OnSelectController(HttpRequestMessage request) in z:\Developing\Visual Studio\Projects\SDammann.WebApi.Versioning\src\SDammann.WebApi.Versioning\VersionedApiControllerSelector.cs:line 70
       at SDammann.WebApi.Versioning.VersionedApiControllerSelector.SelectController(HttpRequestMessage request) in z:\Developing\Visual Studio\Projects\SDammann.WebApi.Versioning\src\SDammann.WebApi.Versioning\VersionedApiControllerSelector.cs:line 61
       at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
  InnerException: 

richardp-au avatar Mar 03 '15 13:03 richardp-au