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 implementing our Razor class library, we will learn about a Visual Studio Code feature, which is a compact folder feature. 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 the figure:

Get hands-on with 1400+ tech skills courses.