0

In some of the classic descriptions of MVC, the Model notifies Views via the observer pattern. It seems to me that this doesn't happen with ASP.NET MVC, and so one of the fundamental relationships between Model, View, and Controller is missing.

Is this the case? If so, why?

2 Answers 2

2

Views in ASP.NET MVC are Stateless. They exist for a very short time and then are sent down to the client.

The process goes something like this:

  1. Request comes in to the Controller.

  2. Controller retrieves the Model and instantiates the View (passing it the Model).

  3. The View is rendered, the markup returned to the client, and then disposed of.

Therefore, since the View no longer exists after it is sent to the client...there's nothing to notify about Model changes.

Sign up to request clarification or add additional context in comments.

2 Comments

I feel like this is a flame-war type of question, but is ASP.NET MVC truly MVC, then?
@Hobbes - It is. It's the web adaptation of the pattern. If you would say not, I would argue then that none of the other Web MVC frameworks are MVC either.
0

Observer pattern is not needed. In the original definition of View it says:

A view is attached to its model (or model part) and gets the data necessary for the presentation from the model by asking questions.

http://heim.ifi.uio.no/~trygver/2007/MVC_Originals.pdf

In the context of a web app, the only View possible is markup (HTML/XML) rendered by a browser. So, as in ASP.NET MVC, the View code is handed a Model instance that it can access to provide information to the user.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.