C
C#2y ago
ghoulam

❔ 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
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ghoulam
ghoulam2y ago
all the lines
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ghoulam
ghoulam2y ago
i just grouped them for the view
Anton
Anton2y ago
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 request
ghoulam
ghoulam2y ago
this clarified a lot thank you so much
Anton
Anton2y ago
np
Accord
Accord2y ago
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.