- ABP Framework version: v8.3.2
- UI Type: Blazor WASM
- Database System: EF Core (PostgreSQL)
- Tiered (for MVC) or Auth Server Separated (for Angular): no
I'm applying the RequiresFeature attribute to a Blazor WASM Page to prevent pages and components from loading if they do not have the appropriate feature, but it isn't working. I've tried it on both the Razor page and on the Code Behind partial class but neither are working.
The Features documentation at https://abp.io/docs/latest/framework/infrastructure/features states that it only works on dependency injected services but makes an exception for Razor pages and controllers, but there is no mention of support for Blazor components.
Checking the feature using the IFeatureChecker service works fine on other methods.
8 Answer(s)
-
0
hi
I'm applying the RequiresFeature attribute to a Blazor WASM Page to prevent pages and components from loading if they do not have the appropriate feature, but it isn't working. I've tried it on both the Razor page and on the Code Behind partial class but neither are working.
Please share your component code to reproduce the problem.
Thanks.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Blazor Razor Page - TestPage.razor
@page "/testpage" @using Volo.Abp.Features @attribute [Authorize(Permissions.Pages.TestPage)] @attribute [RequiresFeature(Features.Pages.TestPage)] < div > This is a test page < /div >or Blazor Code Behind - TestPage.razor.cs
using System; using Volo.Abp.Features; namespace Pages { [RequiresFeature(Features.Pages.TestPage)] public partial class TestPage { protected override async Task OnInitializedAsync() { // If I put in the FeatureChecker here it works but the page is still half rendered // Would be much better if it worked the same way as the [Authorize] attribute } } }Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
I have confirmed the
FeatureInterceptor/@attribute [RequiresFeature(Features.Pages.TestPage)]will skip the type that inherits fromComponentBase.So you have to use code to check the feature.
Thanks.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Is there a better place to check the Features than inside the OnInitialized event handlers? Doing it in there results in a half-rendered page before it breaks rather than a nice error message like when using the [Authorize] attribute.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Well that is disappointing.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)