BEST
DEALS
OF THE
YEAR!
SAVE UP TO $3,000
LAST DAY 1 DEC
00 Days
00 Hrs
00 Min
00 Sec
Open Closed

Blazor WebApp RequersFeature() hide components from menu even if the feature is true by default #10138


User avatar
0
samirmustafayev created

Hi Abp Team,

I am having an issue with the Features in moduled Blazor Web Application. I have a nuget package wich contains FeatureDefenitionProvider for Groups where defenition provider is located in Domain layer and class for const name in Domay.Shared layer, i am using this groups in my modules to control them by features, by default they are true. When i start programm at first every component that is using RequersFeature() are visible, but then disapears on complete program load. As I understand server can see and detect them thas why it visible but when blazor client loads it make them disapear and in abp/application-configuration/feature:values there is no my custom features. My groups are in database with default values and in UI Settings:FeaturesManagement: groups and children are also visible and working. For example i will show featuresdefenition provider for Saas: Domain

using Payhas.Billing.Platform.Localization;
using Payhas.Common.Features; // this is the nuget package
using Volo.Abp.Features;
using Volo.Abp.Localization;

namespace Payhas.Billing.Platform.Features;

public class SaasFeaturesDefinitionProvider : FeatureDefinitionProvider
{
    public override void Define(IFeatureDefinitionContext context)
    {
        var mainModuleGroup = context.GetGroupOrNull(ModulesFeatures.Main);

        mainModuleGroup?.AddFeature(SaasFeatures.Saas,
           defaultValue: "true",
           L(SaasFeatures.Saas));
    }

    private static LocalizableString L(string name)
    {
        return LocalizableString.Create<PlatformResource>("Features:" + name);
    }
}

DomainShared:

using Payhas.Common.Features;
using Volo.Abp.Reflection;

namespace Payhas.Billing.Platform.Features;

public class SaasFeatures
{
    public const string Saas = ModulesFeatures.Main + ".Saas";

    public static string[] GetAll()
    {
        return ReflectionHelper.GetPublicConstantsRecursively(typeof(SaasFeatures));
    }
}

Blazor.Client: Navigation MenuContributor

//Saas
 var saas = context.Menu.GetMenuItem(SaasHostMenus.GroupName);
 saas.RequireFeatures(SaasFeatures.Saas);

<br>


2 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    1. Solution
    • Root cause

      • In Blazor Web App, menus are built on the server first, then the client (WASM-side) re-hydrates and re-evaluates feature/permission requirements using values coming from the Application Configuration endpoint. If your custom feature definitions are not exposed to the client, RequireFeatures(...) will hide items after client load.
      • Features are only sent to the client if each feature definition:
        • Belongs to a registered Feature Group, and
        • Is visible to clients (IsVisibleToClients = true), and
        • The FeatureDefinitionProvider is discovered in the running app (module dependency path).
    • What to do

      1. Ensure your FeatureDefinition is visible to clients
    public class SaasFeaturesDefinitionProvider : FeatureDefinitionProvider
      {
          public override void Define(IFeatureDefinitionContext context)
          {
              var group = context.GetGroupOrNull(ModulesFeatures.Main)
                         ?? context.AddGroup(ModulesFeatures.Main, L("MainFeatures"));
    
              group.AddFeature(
                  SaasFeatures.Saas,
                  defaultValue: "true",
                  displayName: L(SaasFeatures.Saas),
                  isVisibleToClients: true // <<< important
              );
          }
    
          private static LocalizableString L(string name)
              => LocalizableString.Create<PlatformResource>("Features:" + name);
      }
    
    1. Make sure the Feature Group exists in the same Define call path
    • If your ModulesFeatures.Main group is defined in a shared NuGet, ensure that group is created before adding features. If not already created in that package, add it as shown above with context.AddGroup(...).
    1. Verify the module dependency path so the provider is discovered
    • The assembly that contains SaasFeaturesDefinitionProvider must be referenced and its module must be depended on by the application:
    [DependsOn(
          typeof(AbpFeaturesModule)
          // + your package/module that contains the FeatureDefinitionProvider
      )]
      public class PlatformDomainModule : AbpModule
      {
      }
    
    • Ensure the package is referenced by the final app (HttpApi.Host for server, and the Blazor project if it needs types). The provider must be in a module that is part of the server app’s module graph so the server can define and expose features.
    1. Do not mark the feature as not visible later
    • Avoid setting IsVisibleToClients = false anywhere via options or additional providers.
    1. Confirm from the client that the feature is delivered
    • After the above changes, the application-configuration response should include your feature under features.values.
    • If it still doesn’t appear, clear caches and ensure you’ve run the migrator and restarted the app.
    1. Using RequireFeatures on the menu
    • With the feature now visible to clients, the item will remain visible after client load:
    var saas = context.Menu.GetMenuItem(SaasHostMenus.GroupName);
      saas.RequireFeatures(SaasFeatures.Saas);
    
    1. Notes on defaultValue and database values
    • defaultValue: "true" is used only if there is no stored value. If you manage the feature in UI, the database value takes precedence.

    • Ensure the tenant/host you are testing has the feature enabled in the Features modal.

    • Quick checklist

      • [ ] Feature group exists (context.AddGroup or previously defined).
      • [ ] AddFeature(... isVisibleToClients: true).
      • [ ] Provider assembly is loaded and module is in dependency chain.
      • [ ] application-configuration features.values contains your key.
      • [ ] Menu item uses RequireFeatures with the correct full feature name.
    1. Sources
    • Features basics and client visibility:
      • https://github.com/abpframework/abp (project source reference)
      • This approach aligns with the official “Features” documentation statement: “A feature value is available at the client side too, unless you set IsVisibleToClients to false on the feature definition.”

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Is your webapp tiered?

    abp/application-configuration/

    Does this endpoint's website depend on your feature definition package?


    How can I reproduce this problem in a new webapp template project?

    Can you share the code and steps?

    liming.ma@volosoft.com

    Thanks.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on November 20, 2025, 09:12
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.