❔ Can anyone explain how this actually work?
Hi,
I've been learning how to build APIs lately and i am having a hard time accepting this piece of code and not thinking about how it actually works.
Can anyone help ?
Thanks in advance.
8 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
all the lines
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
i just grouped them for the view
this just creates the context for initializing and configuring your web aplication (builder). web app means an aspnet core http server. The futute calls just build up that context.
AddControllers
uses reflection to find all controller classes in the current assembly (I think) and registers them with the context. The last line is dependency injection, google "dependency injection container"
AddScoped
means one instance per requestthis clarified a lot thank you so much
np
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.