Using Razor class libraries
Everything related to a Razor Page can be compiled into a class library for easier reuse in multiple projects. With ASP.NET Core 3.0 and later, this can include static files such as HTML, CSS, JavaScript libraries, and media assets such as image files. A website can either use the Razor Page’s view as defined in the class library or override it.
Disabling compact folders for Visual Studio Code
Before we implement our Razor class library, I want to explain a Visual Studio Code feature that confused some readers of a previous edition because the feature was added after publishing.
The compact folders feature means that nested folders such as /Areas/MyFeature/Pages/
are shown in a compact form if the intermediate folders in the hierarchy do not contain files, as shown in Figure 13.8:
Figure 13.8: Compact folders enabled or disabled
If you would like to disable the Visual Studio Code compact folders feature, complete the following...