Open Closed

Disable the audit for the API, #6563


User avatar
0
dev@veek.vn created

Hi, I want to disable the audit for the API, but it doesn't work.

this is my code:

[RemoteService]
[Area("app")]
[ControllerName("Job")]
[Route("api/app/jobs")]`

[DisableAuditing]
[HttpGet]
[Route("sync-robot-drivers")]
public Task SyncRobotCodesHasDriver()
{
    return _jobAppService.SyncRobotCodesHasDriver();
}

Configure<AbpAspNetCoreAuditingOptions>(options =>
{
    var ignoredUrls = new[]
    {
        "/jobs",
    };
    
    foreach (var url in ignoredUrls)
    {
        options.IgnoredUrls.AddIfNotContains(url);
    }
});

ABP Framework version: v.7.3.2 UI Type: Angular Database System: MongoDB Tiered (for MVC) or Auth Server Separated (for Angular): yes Exception message and full stack trace: Steps to reproduce the issue:


8 Answer(s)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello ,

    Please check this similar issue https://support.abp.io/QA/Questions/3901/DisableAuditing-not-working-on-Controller-and-Controller-Action

    Thank you.

  • User Avatar
    0
    dev@veek.vn created

    For the route "/api/app/jobs/sync-robot-drivers"

    I have setup like this but doesn't work

    var ignoredUrls = new[]
                {
                    "/jobs",
                };
    
    foreach (var url in ignoredUrls)
    {
        options.IgnoredUrls.AddIfNotContains(url);
    }
    
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hi,

    Can you please try with this code

    Configure<AbpAspNetCoreAuditingOptions>(options => { options.IgnoredUrls.AddIfNotContains("/api/app/jobs/sync-robot-drivers"); });

  • User Avatar
    0
    dev@veek.vn created

    Hmm, that's weird, it still isn't working.

  • User Avatar
    0
    dev@veek.vn created

    I have added [DisableAuditing] on controller, api and IgnoredUrls on AbpAspNetCoreAuditingOptions

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hi,

    could you please check is there any logs?

    Can you please confirm once where are you adding this provided code? please check this documentation https://docs.abp.io/en/abp/latest/Audit-Logging#abpaspnetcoreauditingoptions

  • User Avatar
    0
    dev@veek.vn created

    Hi, I have debugged the issue, and although it goes to the highlight, it still stores data in the audit table.

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hi, I have followed below steps and it works properly at my end.

    1. Add AbpAudit Module as a project.

    2. I have added this code in hostmodule.cs file in ConfigureServices() method. Configure<AbpAspNetCoreAuditingOptions>(options => { options.IgnoredUrls.AddIfNotContains("/api/app/books"); });

    3. Add [DisableAuditing] in a controller or appservice.

    After following above steps when I call api the entry is not added in AuditLogs table. I think this is what you want , right ?

    Please let me know , If anything else required.

    Thanks,

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11