Announcing DotVVM 2.5 Preview 2

Published: 8/23/2020 8:16:52 PM

Today we have released a public preview of DotVVM 2.5. Originally, we intended to release it much earlier, but we got a couple of feature requests and bug reports that we wanted to include in 2.5.

The release brings several new features and many stability improvements.


Experimental feature: Explicit assembly loading

Those of you who tried to install DotVVM into an old ASP.NET Web Forms project probably run into several issues with incorrect project references. Until now, DotVVM tried to load all referenced assemblies (including transitive ones) and scan them for various things (namespaces in the @import directive, attached property declarations and so on). This was quite inefficient, and caused problems as the mess references often found in legacy projects prevented the application to run.

Now, it is possible to turn this feature on, and then explicitly list assemblies that DotVVM should work with:

// enable the feature
config.ExperimentalFeatures.ExplicitAssemblyLoading.Enable();

// add assemblies
config.Markup.Assemblies.Add("assemblyName");


Redirection helpers in route table

Sometimes it is useful to be able to register a route which makes a redirect. We’ve seen users writing their own IDotvvmPresenter implementations to do this, and so we added an easier way. You can now use AddRouteRedirection and AddUrlRedirection, which allows you to hook up on a URL you want to redirect, and specify a targer route or URL. There is also an option to process query string and route parameters so the opportunities are endless.

// redirect from "article/15" to "content/article/15"
config.RouteTable.AddUrlRedirection("ArticleRedirection", "article/{id}", c => "content/article/" + c.Parameters["id"]);

// redirect from "calendar" to "calendar/{DateTime.Now.Year}/{DateTime.Now.Month}"
config.RouteTable.Add("Calendar", "calendar/{year}/{month}", "Views/Calendar.dothtml");
config.RouteTable.AddRouteRedirection("CalendarRedirection", "calendar", "Calendar", parametersProvider: (context) => {
    var now = DateTime.Now;
    return new Dictionary<string, object>() 
    {
        { "year", now.Year },
        { "month", now.Month },
    };
});


Startup and background view compilation

Until now, all DotVVM views (pages, master pages and user controls) were compiled on demand - during the first request that needed them. This flow is great for developer inner loop as you typically work with just a few pages you are working on.

// default behavior
dotvvm.Markup.ViewCompilation.Mode = ViewCompilationMode.Lazy;


We have added two new modes for production scenarios:

  • DuringApplicationStart is great when your application is deployed through deployment slots – you deploy the new version to a second instance and wait until it is fully initialized while the traffic still goes to the original instance. When the new version responds to the health-check request, it is switched with the old instance, so there is no downtime. It can be set up quite easily for example in Azure App Service.
    This mode compiles all the views during the startup routine. It increases the app startup time (in larger apps it can take a minute or two) and the app starts responding to the HTTP requests after it has been fully initialized. That’s why it’s a great for deployment slots scenario.
    Do not use this mode without deployments slots unless you don’t care about the downtime – this mode can make the app unavailable for minutes because the view compilation happens during startup.
  • AfterApplicationStart is useful when you don’t have deployment slots. The startup time is similar to the previous versions, and the views will be compiled on a background thread immediately after the startup is finished. If someone accesses a page that hasn’t been compiled yet, it will be compiled immediately, similarly to the Lazy mode.
    If the application makes additional actions after its startup (e. g. populating caches), you can delay the background compilation using the BackgroundCompilationDelay so the CPU is not stressed with too many things at the same time.


There are more features and improvements in this release – see Release notes for all the details.

The final version of DotVVM 2.5 is scheduled to the beginning of September. We are still testing DotVVM 2.5 on our own internal projects to be sure that the release is stable enough.

We’ll be glad to hear feedback or help you with any issues with the release. Get in touch on our Gitter chat.

Tomáš Herceg

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

I am a Microsoft Regional Director and Microsoft Most Valuable Professional.

I am the author of DotVVM, an open source .NET-based web framework which lets you build Line-of-Business applications easily and without writing thousands lines of Javascript code.