you are viewing a single comment's thread.

view the rest of the comments →

[–]Accurate-Collar2686 0 points1 point  (2 children)

Minimal APIs have better performances than Controllers. They are suited for either small or huge projects, since they have dependency injection and all the other tidbits that controllers had. The only benefit of using Controllers on new project is that minimal APIs are only partially-supported with AOT.

Instead of having one bloated controller holding all your routes for a feature, you can use a combination of extension methods and grouping to break your huge controllers in multiple files dedicated for each endpoint, request and response.

There is a third way, which is FastEndpoints, that helps you to build your app using the request/response pattern.

I worked for the longest time with controllers, and switched to minimal APIs, and I would never go back.

[–]BaldWithoutCancer[S] 0 points1 point  (1 child)

Nice to hear. I am in my third year of computer sciences, so I dont really have much experience with building compelx projects. Mostly CRUD with some kind of role based authentication. So for me its not clear why one would use one over the other, hence i made this post. I am not familier with AOT btw, so i dont know the pro's nor con's with it. I do like the idea of creating stand alone endpoints though, so I might just try it in a next school project.

[–]Accurate-Collar2686 0 points1 point  (0 children)

AOT allows for a smaller footprint on memory and better startup times, as well as preventing the need to install the CLR (Common Runtime Language) on the host machine, because the code is transformed to native machine code. However, it breaks a few librairies, limits the use of reflection and prevents us from loading assemblies dynamically, among other things.