[RESOLVED]How is ASP.MVC different from ASP.NET Web forms

Hello Guys,

Sorry If this has been asked earlier.

I am beginner to ASP.NET MVC and I have one question on MVC as below -

My Question is -

ASP.NET Web forms has logic separated with BAL, DAL layer in the project and ASP.MVC provides the same with Model, Controller and View layer.

So, whats the difference between ASP.NET Web forms and ASP.NET MVC??? Please help me to understand this.

Thanks in advance,

JJoe123 

1. In MVC, More logic in Controllers. So you can write more tests and encourages Test Driven Development. In web forms, you intend to do more logic in code behind which will be later hard to do the unit testing. 

2. The starting point of the core logic in webforms is aspx/aspx.cs (UI) page but here the starting point of the core logic would be Controller which accepts the requests. 

3. aspx and aspx.cs are tightly dependent on each other and can’t server as a separate layers. Where as in MVC, you have Controllers and Views are different layers altogether. One view can be reused for multiple controllers.

4. No postback, No viewstate mechanisms in MVC which exists in webforms – So a bit lighter compared to webforms.

5. Webforms offers good and easy drag-and-drop controls for easy development – not in MVC.

So there are lot of pros and cons like this but above are main important things to remember.

See Rion’s response for this topic for a list of good bullet points:

http://forums.asp.net/t/1923089.aspx?Webforms+or+MVC

Few other posts you can read:

http://www.seguetech.com/blog/2013/12/05/dotnet-web-forms-vs-mvc-which-better

http://programmers.stackexchange.com/questions/95212/when-to-favor-asp-net-webforms-over-mvc

WebForms and MVC are presentation layers – things like BAL and DAL etc are nothing to do with web forms, they are just how some people choose to architect their solution.  Also the M, V and C layers are not analogous to presentation, business and data. 
There are many articles already comparing the two but ultimately it is just a different paradigm with webforms and mvc having different focusses on their development.  WebForms tries to abstract from the developer the workings of html (eg you don’t need to
know the markup for how to make a form or a checkbox work, you just use asp:Form and asp:Checkbox), and it also hides the workings of http as it uses the postback mechanism to populate your control properties with the submitted data.  It has drawbacks concerning
testability though.  MVC has helpers to help with create the html elements to a certain extent, but there is less emphasis on the framework generating the html for you, and an understanding of html and http is more of a requirement.  Instead of the postback
mechanism in webforms, MVC uses model binding to map the form submission to .net objects.  In that respect it is still abstracting a lot of how http works, but nowhere near the extent to which webforms did.

It’s a big subject so best do some googling, or try both out yourself and you’ll get to understand the differences more.

http://msdn.microsoft.com/en-us/magazine/dd942833.aspx

http://www.webdevelopmenthelp.net/2013/10/difference-between-asp-net-webform-and-asp-net-mvc.html

Siva Krishna Macha

1. In MVC, More logic in Controllers. So you can write more tests and encourages Test Driven Development. In web forms, you intend to do more logic in code behind which will be later hard to do the unit testing. 

2. The starting point of the core logic in webforms is aspx/aspx.cs (UI) page but here the starting point of the core logic would be Controller which accepts the requests. 

3. aspx and aspx.cs are tightly dependent on each other and can’t server as a separate layers. Where as in MVC, you have Controllers and Views are different layers altogether. One view can be reused for multiple controllers.

4. No postback, No viewstate mechanisms in MVC which exists in webforms – So a bit lighter compared to webforms.

5. Webforms offers good and easy drag-and-drop controls for easy development – not in MVC.

So there are lot of pros and cons like this but above are main important things to remember.

See Rion’s response for this topic for a list of good bullet points:

http://forums.asp.net/t/1923089.aspx?Webforms+or+MVC

Few other posts you can read:

http://www.seguetech.com/blog/2013/12/05/dotnet-web-forms-vs-mvc-which-better

http://programmers.stackexchange.com/questions/95212/when-to-favor-asp-net-webforms-over-mvc

Those online topics of webforms bad, mvc good always make me laugh.  99% of problems people have with webforms aren’t problems with webforms but with how they have chosen to use them.  They also talk like the millions of good, powerful, fast, functional
websites already written on webforms don’t exist  They are just bad coders complaining about their tools.  99% if things they say are good because MVC does them are things that WebForms can also do, they just have never done them because no-one told them they
could.  All those bad WebForms developers are now just bad MVC developers, and I guarantee that whenever the thing that replaces MVC comes out people will instantly be saying that MVC is rubbish and that the best thing about <insert new technology> is that
it doesn’t need jQuery to work.

Well said Aidy :). Many developers have tend to say new technology is good without the insights. I completely agree, using the asp.net webforms in good way would definitely produce the good websites. I also agree that both have it’s own pros and cons and
I believe, Rion has listed some nice points in the link I mentioned in original post.

AidyF

WebForms and MVC are presentation layers – things like BAL and DAL etc are nothing to do with web forms, they are just how some people choose to architect their solution.  Also the M, V and C layers are not analogous to presentation, business and data. 
There are many articles already comparing the two but ultimately it is just a different paradigm with webforms and mvc having different focusses on their development. 

Aidy, I agree with your point that things like BAL and DAL have nothing to do with web forms. The thing I want to ask is - 

Does this BAL and DAL layer is similar to Model and Controller in MVC??? If YES how??? and If NO how???

Please explain this point.

Thanks!

Model is simply any class, that will be passed to views to render the content.

Controller will have (or can invoke) the business logic but also acts as the triggering or entry point for the request. In web forms world, aspx page is what the entry point.

Controllers can further call any layers (say a business logic layer BAL or a web api or wcf service) which inturn can call your data access layer DAL.

jjoe123

Does this BAL and DAL layer is similar to Model and Controller in MVC??? If YES how??? and If NO how???

No.

The "Model" in ASP.NET MVC is just a conceptual part of the application which consist of everything that isn’t a controller or view. The ASP.NET Templates produce a folder called "Model" but you can delete that and just add projects containing your BLL and
DAL, or add new folders called DAL and BLL if you like – or structure it in any way that makes sense to you. 

The controller is more closely related to the Code Behind of a web form. It is responsible for determining what should be displayed in the view and what actions needs to be taken according to inputs from users (form submissions).

Leave a Reply