Questions tagged [model-view-controller]

Model–View–Controller (MVC) is an architectural pattern, introduced in mid 1970-s in PARC into how to compose software interfacing also with user-interactions. For Microsoft ASP.NET MVC, please use [asp.net-mvc] or [asp.net-core-mvc] tag instead. For Spring MVC, please use [spring-mvc] tag instead.

Model–View–Controller (MVC) is an architectural pattern used in software engineering, since Palo Alto Research Centre released one such in mid 1970-ies, designed in Smalltalk-79 language.

The pattern isolates "domain logic" (the application logic for the user) from the user interface (input and presentation), permitting independent development, testing, portability and maintenance of each (separation of concerns).

Image which demonstrates typical collaboration of the MVC components:

MVC

Reference

The analogy

MVC can be metaphorically related to a TV. You have various channels, with different information on them supplied by your cable provider (the model). The TV screen displays these channels to you (the view). You pressing the buttons on the remote controls affects what you see and how you see it (the controller).

33635 questions
43
votes
10 answers

Understanding the MVC Pattern

I am having some trouble understanding the MVC Pattern. I do understand we are trying to decouple the GUI from the business logic, although I'm having problems understanding how. From what I understood, the View, is what the user sees. So it…
devoured elysium
  • 101,373
  • 131
  • 340
  • 557
43
votes
7 answers

What's the difference between a ViewModel and Controller?

What are the responsibilities of one vs the other? What kind of logic should go in one vs the other? Which one hits services and databases? How do I decide if my code should go in the viewmodel or the controller? For the record, I am using ASP MVC,…
MedicineMan
  • 15,008
  • 32
  • 101
  • 146
42
votes
4 answers

ember.js and the server

I'm looking at Ember.js and have been reading the docs to try and understand how to use it. I get it (pretty well), except for one thing. To my way of thinking in the MVC pattern, the Model is the repository for data in the application. I can see…
writes_on
  • 1,735
  • 2
  • 22
  • 35
42
votes
2 answers

MVC the simplest example

I'm struggling to understand the MVC pattern. I've been working with MVC frameworks like ASP.NET MVC and Django, but project structure there is pretty much forced, so it really didn't help to understand how to build my own apps based on this…
Kesto
  • 625
  • 1
  • 8
  • 17
42
votes
10 answers

OWIN - Authentication.SignOut() doesn't seem to remove the cookie

I'm having some issues with OWIN Cookie authentication. I have a .Net site that has some MVC pages which uses cookie authentication and WebAPI resources protected by a bearer token. When I log out, I delete the access token on the client, so…
jaeyow
  • 469
  • 1
  • 4
  • 6
42
votes
5 answers

MVC (model-view-controller) - can it be explained in simple terms?

I need to explain to a not-very-technical manager the MVC (model-view-controller) concept and ran into trouble. The problem is that the explanation needs to be on a "your grandma will get it" level - e.g. even the fairly straightforward explanation…
DVK
  • 126,886
  • 32
  • 213
  • 327
42
votes
6 answers

An example of an MVC controller

I have been reading a lot about how and why to use an MVC approach in an application. I have seen and understand examples of a Model, I have seen and understand examples of the View.... but I am STILL kind of fuzzy on the controller. I would really…
BDuelz
  • 3,890
  • 7
  • 39
  • 62
41
votes
4 answers

How to set a hidden value in Razor

I know that what I'm trying to do is bad idea, but I have specific constrains for now. I have multiple sites, using one and the same MVC3 code base. For one of them the requirement is to hide some required fields from the form. I know that the best…
Sunny Milenov
  • 21,990
  • 6
  • 80
  • 106
41
votes
3 answers

When to use Servlet or @Controller

I need to get a few things cleared up. I have been looking for an answer for this one, but I can't seem to find a good answer to my specific questions (eg. this question was nibbling on the answer: Difference between servlet and web service). To my…
Roger
  • 2,684
  • 4
  • 36
  • 51
40
votes
10 answers

Picking a ColdFusion MVC Framework

I am taking over a lot of the ColdFusion stuff that is lingering at our shop and they are insistent it stay on ColdFusion and that new projects in this area MUST be done in CF - basically this part is non-negotiable. I am not very experienced in CF…
naspinski
  • 34,020
  • 36
  • 111
  • 167
40
votes
7 answers

Regex for check the input string is just in persian language

I work with MVC and I am new on it. I want to check input values is only in Persian language (Characters) by [RegularExpression] Validation. So I think to use Regex and need to check in range of unicodes, but I don't lnow how can find range of…
Saeid
  • 13,224
  • 32
  • 107
  • 173
39
votes
8 answers

How to structure an enterprise MVC app, and where does Business Logic go?

I am an MVC newbie. As far as I can tell: Controller: deals with routing requests View: deals with presentation of data Model: looks a whole lot like a Data Access layer Where does the Business Logic go? Take a large enterprise application…
James
  • 7,877
  • 7
  • 42
  • 57
38
votes
5 answers

Symfony2 disable cache?

Is there a way to disable the caching function in Symfony2? I tried to find the setting in the config* and parameters.ini files and I searched a lot. Ok, I found a few solutions, but nothing for the latest version (Symfony2). WHY? Because I want to…
NaN
  • 3,501
  • 8
  • 44
  • 77
38
votes
7 answers

Migration: No DbContext was found in assembly

Using VS Community 2017. I have tried to create initial migration with error message saying: Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework\Add-Migration' for…
38
votes
4 answers

What to use? MVC, MVP or MVVM or…?

I will start a Java project to develop a desktop application. What to use as presentation layer pattern (MVC, MVP,MVVM or....)? ...if it is possible, with some working small example... :-)
Andrea
  • 803
  • 1
  • 12
  • 27