ASP.NET webforms + ASP.NET Ajax versus ASP.NET MVC

2019-01-21 09:36发布

If given the choice, which path would you take?

ASP.NET Webforms + ASP.NET AJAX

or

ASP.NET MVC + JavaScript Framework of your Choice

Are there any limitations that ASP.NET Webforms / ASP.NET AJAX has vis-a-vis MVC?

14条回答
Juvenile、少年°
2楼-- · 2019-01-21 10:02

My experience has been with programming web apps for apache servers in php and ruby. When I got a job maintaining a web app written in asp.net (webforms), I dove into learning the microsoft way of building web apps. I will have to say I was completely mortified! I was thinking WTF is all this viewstate garbage being sent back in forth? Is this even necessary?

And then I decided to look at doing some simple things with ajax and jquery, which lead me to update panels and clientIDs being generated, and not what I set in the view. What a waste of my time! Why can't I have multiple forms on one page? Why can't I just use regular ajax calls? Why do my views have server logic? These were all questions that im sure that many web programmers face with asp.net webforms. Then, I discovered .NET MVC. My life just got a lot easier.

I was used to using MVC frameworks like Rails and CakePHP to create web apps the way they were meant to be programmed. With technologies actually meant for the web.

My suggestion would be this, Leave WebForms for people that are used to programming winforms type applications because it tries to abstract the fact that you are programming on the web. If you want to have real freedom to develop applications for the web which actually make sense to web programmers, use .NET MVC or something similar that wont get in your way.

Thats my two cents...

查看更多
祖国的老花朵
3楼-- · 2019-01-21 10:04

I've used asp.net winforms with ajax.net as well as prototype/ext/jquery. I guess something to consider is the goal of the site.. MVC is a popular pattern. I can't say anything against ASP MVC because I haven't had a chance to use it, but I want to make sure you know you are not limited to just ajax.net if you chose webforms.

查看更多
迷人小祖宗
4楼-- · 2019-01-21 10:04

I've done both lately, I would take MVC nine times out of ten.

  • I really dislike the implementation of the asp.net ajax controls, I've run into a lot of issues with timing, events, and debugging postback issues. I learned a lot from http://encosia.com/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous/
  • The asp.net project we used the MVP pattern http://www.codeplex.com/aspnetmvp, and the pattern worked great. However we ended up with a lot of code in the view because we were directly interacting with the server side controls (i.e a lot of gridview manipulations). This code is nearly untestable with the unit test frameworks. We should have been more diligent about keeping code out of the view, but in some instances it was just easier and less messy.

The one time I would choose using asp.net forms development would be to use the gridview control. We are using jquery for our javascript framework with MVC and have not yet found a very good gridview like control. We have something that is functional, but the amount of time we have sunk into learning, tweaking, and debugging it vs using asp.net server side controls has been substantial. One looses all of the nice widgets Microsoft provides out of the box doing non asp.net form development. The loss of those widgets is freeing, and scary at the same time when you first start.

At the end of the day I'm happy we are doing MVC development. My team and I have learned a new framework, (we were only asp.net developers before), and have gotten our hands dirty with html and javascript. These are skills we can take onto other projects or other languages if we ever need to.

查看更多
5楼-- · 2019-01-21 10:09

It's been a long time since the original question. Now we have MVC3 and .NET 4

Is MVC now a better solution than before?

查看更多
Evening l夕情丶
6楼-- · 2019-01-21 10:13

The concept behind MVC is great, but be prepared to loose virtually all the functionality of all the server controls you've used for so many years. I've only looked at the MVC implementation for about a week now, but the page lifecycle and view state are gone so these controls no longer function properly.

I was also stunned to find a number of examples containing a lot of logic code in the markup. That's right, 'if' and 'foreach' statements in the aspx files -- a horrible step backwards imho. I was very happy to leave classic asp behind but in the current implementation of the asp.net mvc pattern you're back to code in your markup, the need to use helpers everywhere, and the lack of virtually any useable server controls.

If you're starting a new project now I'd recommend sticking with asp.net webforms and make use of a the built in asp.net ajax, the toolkit, and jQuery as needed. The asp.net ajax implementation may not be the absolute best, or most efficient implementation, but unless you're getting a million uniques on day 1 or your server is a commodore vic 20 the performance hit isn't going to be that noticeable.

This of course does depend on your project size. If you're starting a 5 year Enterprise level application that expect millions of page views, UpdatePanel might not cut it, but if you're building an average site, throwing up a prototype, or just need to get moving fast, asp.net ajax works perfectly fine and has an extremely low learning curve.

And to be clear, the entire page is absolutely not returned every time an ajax call is made. /Only/ the content for the panel that needs to be updated is sent across the wire. Any http monitor will prove this point. Yes, the page /lifecycle/ is performed, but knowing that you can can build fairly efficient asp.net ajax applications.

查看更多
啃猪蹄的小仙女
7楼-- · 2019-01-21 10:15

Webforms with ASP.NET Ajax is heaven. The integration between the 2 is just amazing and feels so natural to work with.

Using webforms instead of mvc will give you the ability to utilize the lifecycle to develop very good and re-usable controls.

But I still like to add a little jQuery into the mix for traversing the dom and adding animations, I just like to use asp.net ajax to get the integration with the server side.

查看更多
登录 后发表回答