开发者

How to decide on WebForms vs ASP.NET MVC 3 for new project? [duplicate]

This question already has answers here: 开发者_如何学Python Closed 11 years ago.

Possible Duplicate:

MVC versus WebForms

ASP.NET MVC Performance

I'll be starting a new web project in the coming weeks. It's a public facing web site for a somewhat famous person. I have 2 choices: use good-old ASP.NET 4 or new ASP.NET MVC 3 with Razor.

I do not plan to do any kind of unit testing. It's rather simple website mainly consisting of javascript, html and css.

I'll need to build an admin panel to create/delete/edit pages; add/remove pictures to portfolio gallery. And that's probably all I need from an admin panel. Nothing complicated.

Disclaimer: I do not have much experience with either Webforms or MVC, other than what I have learned from Pluralsight Training and ASP.NET Official Tutorials. I do have intermediate knowledge of css and html; no experience with javascript. But given how javascript is so similar to other OOP languages I am not too worried if I have to get my hands dirty with JS.

  • In terms of development speed, which would be faster: WebForms or MVC?
  • How about out-of-box performance between the two?
  • In a long term which would be easier to maintain?

If you advise against starting a web project from scratch, perhaps you could recommend a light ASP.NET CMS instead?


In terms of development speed, which would be faster: webforms or mvc?

This depends on many factors, but suppose that you use eqal technologies both with webforms and mvc then mvc should be faster. Webforms has some overhead because of the mismatch between how things really work (eg. that http is stateless) and what is assumed while writing the code (you're programming as if the application was stateful)

In a long term which would be easier to maintain?

IMO MVC is easier to maintain, because it's easier to change bare html/js code, the model(MVC) is well defined which makes it less painful for a new person to get to figure out how everything works.

I'll need to build an admin panel to create/delete/edit pages; add/remove pictures to portfolio gallery.

This is the kind of thing that MVC is good with - define entities and quickly create List/Details/Create/Edit/Delete actions and views.

PS> I'm not saying that plain old ASP.NET Webforms is bad, it's just that it sometimes becomes too complicated and you need to pay the price for it. I think that open source e-commerce solution - NopCommerce is a good example. It's well designed, well written, but it's really slow because of the overhead that is needed for web forms.


In terms of development speed, which would be faster: webforms or mvc?

WebForms can be a little faster to develop since it's a lot of R.A.D. development. Long term however, you will regret not separating your concerns. Keeping a separation of concerns may take longer but is a lot easier to maintain after the fact.

How about out-of-box performance between the two?

MVC will perform better since there is no "extras" being passed between the controller and the View. you only pass what's necessary (IE: no ViewState)

In a long term which would be easier to maintain?

Back to what I mentioned above. Keeping a separation of concerns may take longer but is a lot easier to maintain after the fact.


There are pros and cons for both web forms and MVC. But you don't have to choose. You can use the nuget package for adding MVC to a web forms application. You just have to start with web forms and then it will incorporate the MVC. That way you can have the best of both worlds depending on what your needs are.

Here is the link to that nuget package from Scott Hanselman.

If you are just looking to do a CMS then you should definitely use Orchard


In terms of development speed, which would be faster: webforms or mvc?

Some would argue Web Forms because of the "off the shelf" server controls that can do basically anything you want. Whilst this may have been true in the intial version of MVC, now that we are at v3 and the community is getting heavily involved - you'll be able to find a MVC-port (e.g custom HTML helper) to do those things for you.

Not to mention the vast scaffolding improvements in the MVC tooling will make your "CRUD" life a hell of a lot faster.

So it's hard to categorize "development", but in terms of getting a full page running based on a backend database, i'd say MVC is faster.

How about out-of-box performance between the two?

That's tough to answer. Anything with performance is. I've read somewhere that the Razor view engine is marginally faster than the ASPX view engine, which is what Web Forms is based on. Add onto that things like ViewState, and i'd have to say (without any backing "facts") that MVC would be faster. But don't look to the technology to have well performing applications, look to yourself to write optimal code using the technologies at hand.

In a long term which would be easier to maintain?

Definetely MVC - no question on this one. SoC (seperation of concerns) is a huge pushing point in MVC, not only with the M-V-C segregration, but also the "convention over configuration" approach that is at the heart of MVC. EditorTemplates and DisplayTemplates are a perfect example of this - they work off convention (the model type being passed to it). So you can create multiple templates and flick over different model types without any backend code changes.

That being said - nothing stopping you from having a well seperated and layed out Web Forms application - but there's only so far you can go without hitting a roadblock in the technology itself - such as the "code behind model" which cannot be avoided.

Overall - MVC FTW.


Orchard is the MVC cms of note.

If you are going to pick a pre-built CMS, pick it based on the merits of the CMS. MVC vs Web Forms probably doesn't matter too much here if you know what you are looking to build.

If you are intent in building this yourself and you are comfortable with Html, Css and Javascript then you probably want to do MVC3. Presuming you have some underlying web skills, MVC3 really has erased most of the potential productivity advantages of web forms.


Umbraco is a free CMS, awesome and .NET based.

http://umbraco.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜