- read

Why Does Microsoft Still Stick with ApiControllers?

Rico Fritzsche 50

Why Does Microsoft Still Stick with ApiControllers?

Deconstructing Web API Paradigms: Controllers, Minimal APIs, and the Road Ahead

Rico Fritzsche
Level Up Coding
Published in
6 min read2 hours ago

--

Licensed under the Unsplash+ License

The evolution of C# and its .NET Core framework has been nothing short of remarkable, establishing itself as a top-tier choice for robust applications and services. Yet, as I’ve journeyed alongside its growth, a recurring question emerges: “In an age where REST APIs and Domain-Driven Design (DDD) principles reign supreme, why does Microsoft still advocate for the use of ApiControllers?” This conundrum becomes even more exciting when you consider that the term “controller” often seems inappropriate in this domain-centric world.

MVC and the Role of Controllers

In traditional web development, the Model-View-Controller (MVC) architecture stands out prominently. Controllers within this framework have a well-defined role, bridging the model (data) with the view (UI). This ensures that user input gets transformed into commands, either for the model or the view. When you’re dealing with UI interactions, controllers indeed make sense and are an integral part of the MVC construct.

Yet, when the focus shifts to DDD, we dive deep into the heart of our software, which is its domain — a meticulous reflection of intricate business logic and complexities. The approach here is about understanding and modeling the ubiquitous language, aggregates, entities, and value objects. It’s a departure from the UI-centric world that controllers typically inhabit.

However, when transitioning from the UI-focused MVC paradigm to the data-driven REST paradigm, the role of controllers becomes less clear.

Controllers in RESTful Systems

Moreover, in the realm of RESTful APIs, the traditional MVC ‘view’ is conspicuously absent. Here, the narrative is about data interchange, not about how the data is presented or visualized. So, using ‘controller’ in this context feels semantically incongruent. What we’re really talking about is managing data requests and responses, a role that doesn’t quite resonate with the established duties of an MVC controller.

Cautious Stories from Tutorials