.netblazorrazor-class-library

Razor Class Library - can it contains Classes


I am developing a .Net 6 Blazor Server app and im creating a seperate RazorClassLibrary to store my .razor components. Which is going well. I was wondering can I store classes within a RazorClassLibrary. I created a class in it as one of my controls was using it to store an enum, but when i try and set a parameter that references the emnum in that class I cant seem to find it from my BlazorServer app.

Is a RazorClassLibrary for .razor compoenents only. One of my controls has a lot of enums etc... and I cant seem to expose them very well.

TIA


Solution

  • Yes - absolutely. To can add anything into a Razor Class Library RCL and you can use them in both WASM Client and Server Projects.

    Check that you have included you RCL in your project and that you have added a project reference to your Server Project. Once that's done you need to make sure that your class and enum are marked as public.