I'm building a site similar to StackOverflow, mostly as a learning exercise, and I'm having difficulty understanding how to decide on the different controllers in the MVC pattern.
What exactly is a controller? What controllers would you use to model a Q&A website similar to SO? I'm using ASP.Net MVC, and I notice the URL pattern is always "/Controller/Action" - but that is definitely not how I'd like the final URLs to look like ("/Question/123" does not fit into that pattern). Is that a consideration?
I know this is actually a mix of several questions ... perhaps what I really need is a good tutorial to understand the basics.
Also, MVC relies heavily on reflection, which allows you to inspect types at runtime using strings. Reflection is used in many programming frameworks.
-MVC is an architectural pattern consisting of three parts: Model, View, Controller. Model: Handles data logic. View: It displays the information from the model to the user. Controller: It controls the data flow into a model object and updates the view whenever data changes.
In simple words, a controller is a contract/bridge between a model and the view.
Here is the flow:
A controller is used for main request processing logic. If a page has to talk with database, the controller sends a request to the model, model performs its task with db and returns some response or db records back to the controller then controller sends this response to the view.
The below picture explains the process more easily:
(source: shopno-dinga.com)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With