MVC vs Web Forms in EPiServer 7

You have a choice which one to use when you are building an EPiServer 7 website. IMHO this option is only to give developers familiar with Web Forms, some time to jump to MVC. Like there was Visual Basic .NET together with C#, and the first one is of course slowly dying now.

I have been developing on EPiServer 7 for one year now (almost from start). First four months with Web Forms and it was last time I used them. From then until now I am working with MVC.

Pros of MVC

  • Joel Abrahamson writes a book about EpiServer 7 (in MVC, only side notes for Web Forms). Last update.
  • As I look on blog posts on http://world.episerver.com/Blogs/, most of them write in MVC, and with a time it will be more and more.
  • There are concepts that are built in like friendly URL, WebAPI (no need to use external libraries like Nancy).
  • MVC is the next generation, has better separation of concerns (Model/View/Controller), while in Web Forms you create by default mixed/spaghetti code.
  • Because of above point writing code in MVC is more fun, Razor views means less code, generally better IoC, testing, etc.

Pros of Web Forms (I don’t suffer from any of them, but they may occur)

  • You have no experience in MVC and don’t want to experiment with new technology. It requires learning – no doubt.
  • There is some code that you need written in aspx markup that works fine and will still work (i.e. in Admin Mode) so you don’t want to develop together Web Forms and MVC.
  • Honestly I don’t see any good reason to start new project with Web Forms. But please share in the comment, when you see any.

The goal

This article is sponsored 😉 By my desire that 3 developers that are right now starting next project will choose MVC. And there will be another new MVC project in Making Waves.

Advertisements
Ten wpis został opublikowany w kategorii EpiServer i oznaczony tagami , , , . Dodaj zakładkę do bezpośredniego odnośnika.

2 odpowiedzi na „MVC vs Web Forms in EPiServer 7

  1. Grzegorz W pisze:

    Jeszcze 2 lata temu miałem takie samo zdanie jak wyżej przez Ciebie przedstawione. WebForms to schyłek, a przyszłością jest tylko MVC. Od tego czasu jednak trochę się zmieniło – musiałem pracować nad projektem stworzonym w WebForms. Początek był koszmarny, kod spaghetti, absolutny brak testów itd.

    Ale… już od roku kod jest ułożony i to co dzieje się w Code behind służy jedynie do wyciągnięcia informacji z ViewModel. Dokładnie Tak – w WebForms mam ViewModel i to działa 🙂

    W tym momencie MVC używam cały czas w większości projektów, ale jeśli mam przed sobą projekt który jest typową aplikacją biznesową poważnie rozważam czy WebForms nie będzie lepszym rozwiązaniem.

  2. I can’t agree with „MVC is the next generation”. Webforms and MVC will live alongside. Both have their purposes.

    You can write good code with Webforms and avoid spaghetti code. Just as you can write spaghetti code in MVC.

    It’s easier to share code and functionality in Webforms thanks to web controls and especially templated web controls.

    Most of the stuff that was introduced in MVC, like model binding and routing, is ported to Webforms as well.

    Yes, Razor is cool. But you tend to write a lot of markup in code files instead when implementing html helpers. And views tend to be cluttered with a lot of code mixed with markup.

    The whole viewstate and server form thing in Webforms is really bad though. But convenient for some developers. But that’s easy to fix – just remove the bloody server form.

Możliwość komentowania jest wyłączona.