Do some work after the response in ASP.NET Core

前端 未结 5 1676
梦如初夏
梦如初夏 2021-02-08 03:31

I have an ASP.NET Core website, using EFCore. I would like to do some work like logging to the database, but after having sent the response to the user in order to answer faster

5条回答
  •  情书的邮戳
    2021-02-08 03:48

    Try using Hangfire. Hangfire is an easy way to perform background processing in .NET and .NET Core applications. No Windows Service or separate process required. Backed by persistent storage. Open and free for commercial use.

    You could do something like

    var jobId = BackgroundJob.Enqueue(() => Log(model));
    

    And here is my blog post on using HangFire in ASP.NET Core

提交回复
热议问题