What Exactly Is DotVVM?

Published: 8/29/2016 2:22:00 PM

This looks like a silly question, isn’t it? However, we have found that it is quite difficult to explain what is DotVVM good for in one sentence. The standard answer is “a .NET-based open source web framework for Line-of-Business applications”, but it doesn’t really say anything. DotVVM is actually three things.

 

1. MVVM Framework for Web

Why do we need MVVM on web? The answer is Line-of-Business applications. Most companies need their ERP, CRM or other systems to run on all devices – PCs, tablets and smartphones. Making the application work in a web browser is often the only reasonable way. Line-of-Business applications typically contain complicated forms with hundreds of fields, multi-step wizards, modal dialogs and grid views. Everything is connected, depends on other stuff, if you click on a checkbox, it shows or hides another form fields, modify the validation rules etc.

When you start building such application, you’ll find that the MVVM pattern is an elegant solution for this problem. DotVVM is a framework which lets you write web pages using the MVVM pattern.

 

2. Better ASP.NET Web Forms With .NET Core Support

ASP.NET Web Forms is a broadly used and quite popular technology. There are still many people who prefer it over ASP.NET MVC although it has its issues. DotVVM is inspired by Web Forms and solves the issues Web Forms were criticized for:

 

ViewState: The Curse of Web Forms

Although Microsoft has done a lot of effort to let developers decide what information will be kept in the viewstate, most Web Forms sites suffered with this cryptic hidden field which was transferred to the server and back on every postback.

There is no ViewState in DotVVM. All information that is exchanged between the server and the client during the postback, is JSON serialized viewmodel, your own C# class which contains just the stuff you put into it. You can specify, which properties will be transferred in which direction, you can encrypt or sign parts of the viewmodel, and you can control the amount of data which is transferred.

 

Testability of ViewModels

Every page in ASP.NET Web Forms had its code-behind file. It was almost impossible to test it because you would have to mock many objects.

In DotVVM, you can test your viewmodels. Remember that the viewmodel is always your own C# class. You can create an instance of it, set its properties, call the methods and verify it works. DotVVM also includes mock classes that makes testing even easier.

Also, DotVVM supports injecting dependencies in your viewmodels, so you can use your favorite IoC/DI container.

 

CSS-Styleable HTML

Web Forms tried to make the development easy for beginners so each control offered e.g. an option to set a font size or background color using the FontSize and BackColor properties. However, these properties rendered inline styles which is not a really good approach. There were even some controls, like Menu or Calendar, where you couldn’t turn the inline styles off and the HTML the control produced just couldn’t be styled using CSS nicely. In later versions of Web Forms, it got much better, but still, most control rendered very complicated markup you didn’t want.

DotVVM controls were designed to be styled only with CSS, there are no ForeColor properties which would render inline styles. You can set the class attribute on almost every control and we render the simplest markup that works and that could be adjusted later using the CSS. Also, in the documentation, you can find what the control renders.

 

Other Enhancements and .NET Core Support

ASP.NET Web Forms won’t support .NET Core and most probably, Microsoft won’t invest in them much any more.

DotVVM supports both OWIN and ASP.NET Core. It runs even on Mono on Linux. The DotVVM syntax is different, so you cannot just take your Web Forms application, install the DotVVM NuGet package and run it on .NET Core.

But DotVVM shares many principles, for example the server controls and component-based approach, data-binding, the mechanism of postbacks and page lifecycle. So you won’t have to throw away everything you have learned in Web Forms. You’ll just need to learn how MVVM works and how to better structure your applications (it’s really not a good idea to place the business logic in the viewmodels).

 

3. Rapid Application Development for Line-of-Business Web Apps

DotVVM is an alternative to Angular, React and other popular Javascript frameworks, especially for .NET developers which use these frameworks in combination with ASP.NET Web API today. This approach requires to write thousands of lines of JS code which do nothing than transform the data and send  them over the wire, you have to declare model classes on two places (once in C#, once in Javascript) and you have to deal with stuff like validation or date & time formatting on your own.

DotVVM is a platform for Line-of-Business applications. It handles the server-client communication for you. Despite the fact that DotVVM uses the popular Knockout JS library and utilizes Javascript a lot, you don’t have to write any Javascript code unless you want to build your own controls.

DotVVM handles validation (using the .NET Data Annotations), localization and globalization (the same way .NET Framework does) and many other things you already know from .NET.

The Visual Studio Extension provides the IntelliSense, design-time error checking and other features you are used to.

DotVVM is easy to learn also for beginners. You don’t have to learn anything but HTML, CSS and C#.

 

Try It. You Won’t Regret

DotVVM is an open source framework developed by RIGANTI, a company from Czech Republic. We have built dozens of Line-of-Business web applications. We have tried many technologies including ASP.NET Web Forms, ASP.NET MVC, Knockout, Angular and React.

We have put our best know-how in DotVVM. We love it and it makes us more productive. Try it and you won’t want to go back.

Tomáš Herceg

I am the CEO of RIGANTI, a small software development company located in Prague, Czech Republic.

I am Microsoft Most Valuable Professional and the founder of DotVVM project.