This tutorial shows you how to configure your ASP.NET 1.1 application for view compilation on publish.
- [Instructor] Another new feature in 1.1 is the ability to precompile your views. Now, this requires the Microsoft.AspNetCore.Mvc.Razor.ViewCompilation package, and then you have to update the project file, adding in the tag you see here on your screen, MvcRazorCompileOnPublish, and set that value to true. There's two considerations. Of course, since they're precompiled, the resulting publication bundle is smaller.
But since the views are not shipped in that bundle, they cannot be edited after precompilation. Updated in 2.0 is that views are precompiled by default. So let's look at how this works. To get into the csproj file, you can right-click on the project, say Edit the SpyStore version 11 csproj. I already have it open. Here on line eight is the tag that I had to add in, and I set it to true.
And then I simply did a publish, and I just did a publish to folder, and let's look at the results of that publish. So not precompiled, we have a size on disk of 33.3. And the precompiled version, we have a size on disk of 20.4, so it is a much smaller package. When we look at the precompiled, we see all the dlls. We don't see any views.
So we go all the way down to the bottom. Lots of dlls, no views. The not precompiled publish, we have all of our views. So that simply, you can precompile your views in Asp.NetCore 1.1.
- Running and debugging ASP.NET Core applications
- Pros and cons of migrating existing applications to ASP.NET Core.
- Built-in dependency injection
- Environment awareness and app configuration
- Web host configuration and SSL
- View components invoked as tag helpers
- Configuration and logging
- Using Razor Pages
Skill Level Intermediate
Set up the sample projects4m 49s
1. Get to Know .NET Core
2. ASP.NET Core 1.0
3. ASP.NET Core 1.1
4. ASP.NET Core 2.0
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.