Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to identify client in appservice. #4409


User avatar
0
velu created

Hi,

How can we identify the client details in App service?

Like: Browser, Ip. ( Audit log )

Thanks.


5 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    You can inject IClientInfoProvider and use it like this:

    var browserInfo = ClientInfoProvider.BrowserInfo;
    var clientIpAddress = ClientInfoProvider.ClientIpAddress;
    var clientName = ClientInfoProvider.ComputerName;
    
  • User Avatar
    0
    velu created

    Hi,

    Is there any way to trigger user-defined class, When any web-API called.

    Like-- When user triggered create user app-services or any other service[Webapi] then we want to trigger [user-defined class] with auditing details.

    eg. like insert in Abpauditlog.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    If you need something other than AuditLogs, you can create a similar interceptor like AuditingInterceptor, see <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp/Auditing/AuditingInterceptor.cs">https://github.com/aspnetboilerplate/as ... rceptor.cs</a>.

    You can check it's usage in ABP Framework.

  • User Avatar
    0
    velu created

    Hi,

    Can you suggest me a way to trigger AuditingTrigger Class for the each and every web-API request?

    We need to trigger this automatically on web-API call.

    Thanks

  • User Avatar
    0
    aaron created
    Support Team

    Refer to this Stack Overflow answer on how to inject IClientInfoProvider in a custom interceptor: Authorize application service based on client IP address

    You can:

    • Skip the attribute.
    • Modify ShouldIntercept to return typeof(IApplicationService).IsAssignableFrom(type);
    • Inject and call AuditingTrigger in the Intercept method.