blah blah blah is here! blah blah » Close

up0down
link

Hi all,
What are the pros and cons on the issue between mvc framework vs. asp.net webforms architecture.
I know that with webforms you have postbacks, page life cycle events, viewstate to render controls back to their previous state, build in validation and html controls etc.
Now with MVC you don't have viewstate, postbacks etc., you basically get total control over the HTML now. So you have have multiple forms, clean CSS since they are all generated by the developer now.
One thing I was reading about is that with MVC you can easily do Unit Testing now with mock objects. Since there is a cleaner seperation between a controller, model and views you can easily plug in the inputs for each 'layer' and test your code. I think unit testing is a big feature that will help many developers, honestly I haven't done much unit testing as of yet but I am anxious to!
Another benefit with MVC is that you can create SEO (search engine optimized) URL's, meaning you can creating extensionless urls now, and create urls that appear to be static in nature (which helps search engines spider the site), no more querystring based urls or hacking the architecture with Rewriting.
What do you guys see as the drawbacks to the MVC framework?

last answered 3 months ago

1 answers

up0down
link

actually you can do most of that w/ web forms as well. a while back I posted a mod_rewrite solution that fits into an asp.net website / web project and lets you do the sef urls.
postbacks are form posts, which is http and still exists w/ an mvc architecture.
the main difference is the way you go about designing and implementing your website. rather than building some UI, you build the application. web forms tried to make creating websites similar to making windows applications under the windows forms designer in .net. but the problem with that is, that http/html is a stateless technology, and windows development isn't. while you handle a button click in a windows app using a memory address held by the delegate (function pointer) to execute some arbitrary code using an ever present application state, in web forms, you have to create a state machine that builds / destroys your application "window" with every "event" (ie an HTTP form post). IMO web forms and asp.net in general is a terrible design. I've been saying this since I first learned about how it works.
what MVC allows you to do is to write your application the same way you'd write any application. it is a design pattern, not a technology or framework. I follow the same pattern in windows development.
with mvc you create a "view" of your object that is used to "render" it to the user. the controller processes input from the user which may change what the model (the data you're working with) "looks" like. that look is then updated in its view.
MVC is the way the rest of the web technologies work. IMO its the way .net should have worked from the get go, but they let some idiot decide not to go that direction till there were enough people using their technology to really get volume feedback on how awful it is.
MVC can require a substantial amount less processing per request, making your application much more efficient. of course if you like all the wysiwyg (which sucked in asp.net designers anyway) thats going to drop of to some extent w/ MVC, though the way microsoft works, I'm sure they'll find a way to make something neat for that as well.

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback