Is using a web api like dll possible?

Asked

Viewed 53 times

0

After the Publish of a Web API project I added in the dll references of this API in another Solution, the intention is to "consume" this API without httpclient, to access the controller methods of this API.

That’s possible?

I tried but when I call the namespace apiService.Controller.Testecontroller() is required the interface that is in the controller injection, and I do not have access to it by the DLL, so it comes hot if it is possible what I am trying to do, if yes where I am missing?

  • 1

    It’s even possible, but it’s kind of a weird thing to do. Anyway, how do you want to create an instance of TesteController without passing the constructor parameters? You see, if there’s something being "injected" into the constructor, it’s because the controller uses it, if the controller uses it and you don’t pass it to it, how it would work?

  • It is, but in the API project has an injection container that solves this, after compiled it should not be all working?

  • 2

    That’s not how it works. I suggest you stop and study a little bit about how this dependency injection works.

  • I abandoned the idea, I saw that it is very gambiarra that I am thinking of doing, thanks for the help.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.