| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The primary benefits of compiled views is improved performance by eliminating compile times of Razor views. They can also provide static compilation benefits by highlighting compile errors during development and can simplify deployment by avoiding the need to deploy any *.cshtml files as they end up pre-compiled in the containing Assembly.
To enable compiled razor views you need to add the ServiceStack.Razor.BuildTask NuGet Package to the project containing your Razor *.cshtml pages, i.e:
PM> Install-Package ServiceStack.Razor.BuildTask
This doesn't add any additional dlls to your project, instead it just sets the BuildAction to all *.cshtml pages to Content and registers an MSBuild task to your .csproj project file set to pre-compile razor views on every build.
To register assemblies containing compiled razor views with Razor Format you just need to add it to RazorFormat.LoadFromAssemblies, e.g:
Plugins.Add(new RazorFormat {
LoadFromAssemblies = { typeof(RockstarsService).Assembly }
});The Compiled Views support continues to retain a great development experience in DebugMode as all Razor Views are initially loaded from the Assembly but also continues to monitor the file system for modified views, automatically compiling and loading them on the fly so AppDomain reloads aren't required to see changes.
The RazorRockstars.CompiledViews VS.NET project shows an example of Razor Rockstars which uses shared compiled Razor Views in a .dll in a number of different projects:
The ServiceStack.Gap project shows how to extend Compiled Razor Views and use them to create embedded ServiceStack solutions that can be ILMerged down to a single .exe.
Getting Started
Designing APIs
Reference
Clients
Formats
View Engines 4. Razor & Markdown Razor
Hosts
Security
Advanced
Caching
HTTP Caching 1. CacheResponse Attribute 2. Cache Aware Clients
Auto Query
AutoQuery Data 1. AutoQuery Memory 2. AutoQuery Service 3. AutoQuery DynamoDB
Server Events
Service Gateway
Encrypted Messaging
Plugins
Tests
ServiceStackVS
Other Languages
Amazon Web Services
Deployment
Install 3rd Party Products
Use Cases
Performance
Other Products
Future
| Back | FazBrowse Home | New Git URL |