0

I have a Self Host ASP.net WEB API v.4.0.20710.0, that is a legacy package which I got via NuGet.

So my question is if it is possible to get an reference of my logging class to a controller, because they seem to get instanciated somewhere in external code that I can not access.

The only possible solution I see is to make the logging class static, but that would be really uncomfortable. Any other ideas?

3
  • 1
    Please read How to Ask and share your research. You're looking for something called "dependency injection", and there's been written plenty about that subject. See for example Using WebApi and structure map dependency injection. Commented May 17, 2016 at 13:50
  • @CodeCaster Thank you but that seems not to be quite the answer, mabye I just don't get it through. I am using .net 4.0 and therefore it seems that I dont have access to that GlobalConfiguration Commented May 17, 2016 at 14:23
  • 1
    If you mean you use WebAPI 1, you'll have some class like WebApiConfig with a method Register(HttpConfiguration config), where you can access config.DependencyResolver. Commented May 17, 2016 at 14:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.