Razor templates - First startup slow (precompile?)

Hi there!

While running ServiceStack, dotnet core, on a Raspberry Pi, i noticed that first load of my razor view pages is slow.
Once loaded, it goes like a rocket.

I don’t have any specific settings for precompilation, what-so-ever.
Is this solved by setting some options for pre-compilation of razor views, and what would be the recommended setup?

A dirty fix would be the application having to call its-self once during boot, so it’s loaded. (i know…)

What’s best ?

Rob

Is this using Mono or .NET Core? Mono is really slow compiling Razor pages, if you’re using Mono I’d switching to .NET Core pretty much for all projects in future.

Pre-compiling the Razor views will help, there’s an example of using pre-compiled Razor Views in RazorRockstars.CompiledViews.

Otherwise I recommend checking out http://templates.servicestack.net as an alternative to Razor, Template pages don’t need to be compiled as it just uses compiled expressions which will be much faster to load.

I know, Mono is tied to my some of my posts, but i have made my switch to dotnet core in the past months voor my main project. So; its .NET Core!

I will the check pre-compile razor views article. I don’t feel like switching to Templates as my whole front-end is written in Razor views.

Many thanks.

@salorob Just in case, if you are deploying .NET Core 2.0 to a docker environment, a work around is needed for pre-compiled razor views.

You want to use a work around which builds the precompiled views when not publishing to a stand alone deployment.

Issue is also documented here in the note.