Solved

ASP.NET Web Forns or ASP.NET MVC

Posted on 2013-06-30
6
473 Views
Last Modified: 2013-08-19
Hello Experts,

I have developed ASP.NET web applications for years now using ASP.NET Web Forms while using ADO.NET to interact with a SQL database.

My question i have is can someone tell me the difference between using Web Forms and MVC to develop and interact with an SQL database and the pros and cons or each or at least why and for what reasons to use each?
0
Comment
Question by:asp_net2
6 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 39288655
Web Forms was created to help non-web programmers ease into development for the web. If you've ever done Win Forms development, then you know how similar the programming models are. The downside to all this "ease of use" is that a lot of extra cruft gets packed into your pages to help make that model work. Things like View State and all of the extra markup that helps a page determine which button was clicked...that all adds extra data to your pages. Web Forms tends to be larger in terms of payload to the client.

MVC is designed to be more light weight. You no longer have the TextBox, Label, ListBox, etc. controls that Web Forms has; instead you have the standard HTML controls that Web Forms ultimately turns all of its controls into (at page render). MVC doesn't require all of the View State and control tracking that Web Forms does. It functions on the premises that the original web was designed with.

All that said, you can accomplish a good separation of concerns with either approach. It's all in how you style your application. MVC, IMO, lends itself more to adhering to n-tier architecture. After all, ASP.NET MVC is just Microsoft's implementation of the MVC pattern. This is a pattern which by definition creates a separation of concerns between the various parts of your application.

Personally, I have come to like MVC much more than Web Forms. I appreciate the ease of throwing together a web site/application that Web Forms offers. But MVC is very clean in terms of the code and markup. Also, an expansion of MVC called Web API allows you to build RESTful services in an MVC style, very quickly, and very cleanly.
0
 
LVL 4

Author Comment

by:asp_net2
ID: 39288711
Hi Kaufmed,

Thank you for that information. So it sounds like neither is better than the other. I really enjoy working with Web Forms but have not tried MVC yet. I would prefer to just stick with what I have been using for years now. I truly enjoy working with design, programming ASP.NET controls, and programming using ADO.NET.

I was just curious if MVC was better than Web Forms or at least ask if MVC offered more options than web forms.

So I would not be able to work directly with the ASP.NET controls or the different Page Events if I used MVC then???
0
 
LVL 27

Expert Comment

by:Sammy
ID: 39288872
MVC is definitely better than web forms if you plan to do TDD and have concern in regards to Separation of Concerns (SOC)

As for you latest question, you are correct. you cannot using web controls or event driven server controls in MVC project.
You can however use a hybrid project where you can use both MVC and Web forms technologies on the same project.

An advice for your own career, learn MVC... No one is looking for web forms developers anymore (I run a development team and I wouldn't consider a resume if MVC experience isn't listed)

Good luck
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 4

Author Comment

by:asp_net2
ID: 39290531
@sammy1971,

>> An advice for your own career, learn MVC... No one is looking for web forms developers anymore

Why is that? I don't see a TRUE benefit to use MVC over Web Forms. It seems more like user opinion. It also appears that you are limited to what can be done programming wise with MVC than Web Forms or maybe I'm wrong. It seems that Web Forms gives you more interaction with the ASP.NET Controls and Page Events when needed.

I just don't understand the sole purpose of MVC and why some say it's better than Web Forms.

Can someone help me understand in lamens terms why MVC is or is not better than Web Forms?
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 500 total points
ID: 39292163
I've been developing in ASP.NET for 10 years.  I can definitely say I like the MVC model better than webforms.

As well as the reasons posted above by kaufmed, in MVC:
The page lifecycle is simple, unlike webforms
Cleaner HTML, therefore easier to write javascript.  Easier to integrate javascript libraries such as jquery, meaning less reliance on third party controls.
The abstraction is moved from complex web controls to the binding layer  (Once you see this in action, you'll understand why it's genius.)  Your plain old HTML binds automagically to the model object.
Instead of having messy HTML and a sometimes functional event model, you get streamlined HTML and clean object data being posted back to the server.

AJAX is straight forward.  You use javascript and call a method in your controller.
But your mileage may vary.  Also what becomes popular in software development isn't always about what's better.  Often it's about what is new and shiny and cool.
0
 
LVL 27

Expert Comment

by:Sammy
ID: 39292172
Due to the level of abstraction involved in webforms,  it tends to get abused by lazy developers.
This abstraction doesn't exist in mvc, it's just simply developed to follow Web protocols. I have developed in both mvc and Web controls since the release of framework 1.1.
It's simpler, cleaner and more extendable.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now