views:

66

answers:

3

Hi, I am using ASP.NET MVC application. However I am not able to understand the fact that in ASP.NET MVC pages are not posted/no postbacks. How is that possible? Unless posting the data how can the MVC framework manipulate the posted data. So what is the point in telling ASP.NET MVC does not have post backs. And also what the REST principle all about?

Not able to understand from the web contents I have seen. Can anyone explain?

+7  A: 

ASP.NET MVC pages are indeed posted. You need to realize that an ASP.NET 'postback', is nothing more than a regular post from the main (only) form on the page. In MVC, forms also post (just like regular html), but them main difference is they post to a specific controller action.

James Connell
+3  A: 

MVC has posts, just not the WebForm notion of postbacks. In WebForms everything would go back to the form that created it and that form would handle the events and, if applicable, redirect accordingly. This presented, in at least my opinion, a somewhat broken event model representation of web development.

MVC, on the other hand, posts form data to an action on the server side. Any action you want it to, anywhere. That action is the method that handles that post. Not a method for this button and a method for that autopostback dropdown, but a single atomic action that handles that post and returns the next view accordingly.

David
+4  A: 

The difference between ASP.NET posts and ASP.NET MVC posts is that in MVC, your page does not undergo the traditional page lifecycle of ASP.NET. Instead, your posts are mapped to a single method for processing.

Part of the appeal of MVC is that it divorces itself from some of the state-tracking mechanisms of traditional ASP.NET. Since each POST or GET is mapped to an individual controller and method, it becomes less necessary to track things like view state.

By not posting back as much state information and processing a full page lifecycle, the post model is rightly considered characteristically different from traditional web forms, but still relies on the HTTP methods we are familiar with.

With respect to your question about REST, you can read a high-level overview on Wikipedia: http://en.wikipedia.org/wiki/Representational_State_Transfer

kbrimington