I’ll continue my journey using Razor Class Libraries in ASP.NET Core.
Here are my previous posts:
Today I want to cover how you can use static content inside your Razor Class library.
To include static content(images, fonts, stylesheets,…) in your RCL you need to create a wwwroot folder in the class library and include any required files there:
When packing an RCL, all content in the wwwroot folder is automatically included in the package.
As this content becomes part of the DLL you cannot just reference them from the root path(“~”. Instead the path is constructed using ‘_content/{LIBRARY NAME}/’.
For example to reference an example.css file that you stored inside a RCL named ‘Example.RCL’, the correct way to include this css file in your application becomes: