Open Closed

Dynamically Configuring IsEnabledForGetRequests in AuditLog - Blazor #8508


User avatar
0
thanhlg created
  • ABP Framework version: v8.3.0
  • UI Type: Blazor Web App
  • Database System: EF Core (PostgreSQL)

Hi,

I am configuring IsEnabledForGetRequests of AuditLog as false, and I want to add it to the interface so that it can be dynamically changed instead of being hardcoded in the code. How can I do this? Could you provide a code example


1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    According to the document, it is a singleton, and you can directly modify it. https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-9.0#options-interfaces

    public class TestAppService : TestappAppService
    {
        private readonly IOptions<AbpAuditingOptions> _options;
    
        public TestAppService(IOptions<AbpAuditingOptions> options)
        {
            _options = options;
        }
    
        public void ChangeOptions()
        {
            _options.Value.IsEnabledForGetRequests = !_options.Value.IsEnabledForGetRequests;
        }
        
        public bool GetIsEnabledForGetRequests()
        {
            return _options.Value.IsEnabledForGetRequests;
        }
    }
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09