views:

86

answers:

7

Hi, I'm wondering about one thing - as we know, the MVC pattern is stateless (it doesn't use the ViewState, so we use only HTML controls), but if we use them in WebForms as well, it'll become stateless too ? so, by doing this, we are getting closer to the MVC pattern ?

A: 

MVC is an architectual pattern. It can be implemented in any language/framework/environment (although some make it easier than others.)

Pierreten
A: 

I don't know why you would attempt to apply MVC to webforms when all the work has been done for you by Microsoft to implement MVC in ASP.NET with ASP.NET MVC...

Dave Swersky
+4  A: 

You get closer to one aspect of MVC i suppose but its still a night and day difference.

MVC is fundamentally about the model view controller pattern, not what kind of controls your using to write your code. Unless you implement an MVC pattern within webforms (which people did a lot before ASP.NET MVC was released) and migrate away from the postback model in webforms then your platform is still considerably different.

If you want to do that then just use ASP.NET MVC.

JoshReedSchramm
A: 

As with any software models, there isn't necessarily a hard-defined line between fundamental principles. I've been developing applications with loose implementations of MVC in WebForms for years.

The lack of pseudo-state (I won't give WebForms the credit for actual state, the web is stateless) in MVC is one of a number of aspects of the ASP.NET implementation of it, it is not part of the actual MVC pattern.

On top of all this, I can see why people miss Web Controls and want to use them in MVC. But why would you want to use HTML helpers in WebForms? If you're willing to do this type of groundwork then you probably should be using MVC.

David Neale
+1  A: 

No we don't use HTML controls in ASP.NET MVC. We use HTML helpers. There's a big difference.

Darin Dimitrov
A: 

I think you're confused about what stateless means. All web development is stateless, in so far as the server sends down a page to the client and then forgets about it.

.NET tries to make it "easier" by using ViewState and Session, but MVC and Web Forms are stateless.

Jack Marchetti
+2  A: 

ASP.NET WebForms is stateless too. All HTTP communications are. ViewState is just a way of preserving some state by hidden form fields which' values are encoded.

There is nothing stopping you creating your own hidden fields in MVC to make it 'kinda stateful'.

Wim Hollebrandse