Skip to content

Conversation

@watfordgnf
Copy link

This connects the WebApi dependency resolver to ASP.Net WebApi, just like is done for WebForms. This also ensures that optional dependencies do not throw. This was the bare minimum change to this project that enabled it to work for our service.

Also ensure that optional dependencies do not throw.
@ditchcode
Copy link

Same issue here. Thanks for this fix.

@daiplusplus
Copy link
Owner

Thank you for the PR and I apologize for not reviewing it first as I've already fixed it in my own branches and published the updated packages as version 5.0.0-beta01 which fixes this issue (and many others...) in the sample projects in the repo.

https://www.nuget.org/packages/Jehoel.AspNetDependencyInjection/5.0.0-beta01
https://www.nuget.org/packages/Jehoel.AspNetDependencyInjection.Mvc/5.0.0-beta01
https://www.nuget.org/packages/Jehoel.AspNetDependencyInjection.WebApi/5.0.0-beta01

Can you give it a try and if it works great then I'll make 5.0.0 public right-away.


In my approach, I opted to use reflection to get GlobalConfiguration.Configuration so we can avoid needing a hard assembly-reference and NuGet package reference to Microsoft.AspNet.WebApi.WebHost which is separate from the main ASP.NET Web API NuGet package - my approach also allows users to pass-in their own HttpConfiguration instance if they're using Web API in a self-hosted or OWIN-without-ASP.NET-hosting scenario.

Once again, my apologies for not getting back to you sooner - I hate to think I made anyone waste their time :/

I'll leave this PR open just in case further work is needed that you'd like to comment on.

@nathanrobb
Copy link

nathanrobb commented Sep 1, 2021

When are the non-beta 5.0.0 packages being published?

The WebApi v5.0.0-beta2 package fixed my issue, I opted to use the following method and it worked for me (v4 previously didn't work).

.AddWebApiDependencyResolver(HttpConfig)

Edit: tagging @Jehoel thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants