During In-App Purchase implementation in a project. I am working on the ASP.NET WEB API side. I need to use CRON JOB for timely receipt verification on the server side. I want that in-app purchase receipt verification should happen timely from the server side. That is an old project so I want a solution in ASP.NET. I don't have the DI concept in that project.
Loading


Sachin SinghRank #66 · 26.2K reputationPosted Sep 24, 2022, 8:09 AM EDT
You can use hangfire and configure hangfire inside the global.asax file as shown below
using Hangfire; using Hangfire.SqlServer; public class MvcApplication : System.Web.HttpApplication { private IEnumerable GetHangfireServers() { GlobalConfiguration.Configuration .SetDataCompatibilityLevel(CompatibilityLevel.Version_170) .UseSimpleAssemblyNameTypeSerializer() .UseRecommendedSerializerSettings() .UseSqlServerStorage("Server=.\\SQLEXPRESS; Database=HangfireTest; Integrated Security=True;", new SqlServerStorageOptions { CommandBatchMaxTimeout = TimeSpan.FromMinutes(5), SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5), QueuePollInterval = TimeSpan.Zero, UseRecommendedIsolationLevel = true, DisableGlobalLocks = true }); yield return new BackgroundJobServer(); } protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); HangfireAspNet.Use(GetHangfireServers); RecurringJob.AddOrUpdate("myjob", () => YourJobMethod(), cron.daily); } }Documentation:- https://docs.hangfire.io/en/latest/getting-started/aspnet-applications.html