Hi @Hamed Vaziri ,
To access the RCL's static assets from the main project (the Blazor server project), First, place the static assets in the wwwroot
folder of the RCL and reference the static assets with the following path in the app: _content/{PACKAGE ID}/{PATH AND FILE NAME}
. The {PACKAGE ID} placeholder is the library's package ID. The package ID defaults to the project's assembly name if <PackageId> isn't specified in the project file. The {PATH AND FILE NAME} placeholder is path and file name under wwwroot.
For example, I create an Asp.net 6 Razor Class Library (RCL) named "RCLComponentsLib", add a Stylesheet1.css
file in the wwwroot
folder.
the Stylesheet1.css
file:
Then, in the RCL application, there have a component as below:
In the Blazor application, add the app.UseStaticFiles();
middleware and add the RCL project reference. Then, consume the RCL component content like this:
The result like this:
More detail information, see Create an RCL with static assets in the wwwroot folder and Consume content from a referenced RCL.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion