Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to enable interactivity for pages/components within a Razor Class Library for a Blazor App with .NET 8?

$
0
0

I am currently working on developing an application in Blazor with .NET 8, and I am designing it to be modular. The main app is a Blazor project with server-side rendering, and I have structured it so that there is a folder for modules. Inside this folder, I have subfolders, each containing additional projects.

In my current setup, I have a Blazor project within my solution as the main app. This allows me to divide the application into several modules, each consisting of three essential projects. For example:

Module "Configurations":

  • Class LibraryConfigurations.BLL: Business logic for the module.
  • Class LibraryConfigurations.Domain: Models, validations, etc., for the module.
  • Razor Class LibraryConfigurations.UI: Pages/components to be rendered for the module.

I have managed to make my main app recognize the routes of the pages inside the Razor Class Library. However, I am struggling with interactivity. For instance, I cannot add functionality to a button because the attribute @renderMode interactiveServer doesn't seem to be recognized or compatible with this type of project. As a result, I can render the component, but I cannot make it interactive.

What I tried was changing some project settings to enable the use of RazorComponents:

<EnableRazorComponents>true</EnableRazorComponents>

I expected this to make the pages work as Blazor understands and handles these components, but It didn't work.

At this point, I am questioning whether this is the right approach or if there is a better alternative for building this type of modular app.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>