Hello everyone please let me know. I have 100 users in the database, I want all these users to be emailed in bulk. I have done the work of sending the email. Now I have a query that as soon as I click on the button with my email center, the service should continue running in the background, which means the user can click and do something in the application. in.net core with razor pages
Loading
Prasad RaveendranPosted Aug 27, 2023, 2:15 AM
I'm curious to know what was your technical solution to achieve this. If its HostedService or BackGround Service, please confirm whether this has been registed in Starup.cs or in Program.cs depends on your .NET Version you are following
Cr BhargaviPosted Aug 24, 2023, 5:39 AM
Develop a background service class that handles email sending asynchronously and then Register the background service in the
Startup.csusingAddHostedService. Post that Implement theExecuteAsyncmethod in the background service to send emails periodically.In your Razor Page's code-behind, initiate the background service when users click the email send buttonMohammad HussainPosted Aug 24, 2023, 4:36 AM
To achieve background processing for sending bulk emails in an ASP.NET Core Razor Pages application, you can use a combination of background tasks and asynchronous programming. One popular approach is to use the built-in
BackgroundServiceclass along with a message queue system like RabbitMQ or Azure Service Bus. However, for simplicity, I'll demonstrate using theIHostedServiceinterface and a hosted service background task.Jaimin ShethiyaPosted Aug 22, 2023, 5:44 AM
Hello Sunny,
You can use here the Azure service bus or Rabbit MQ concepts like Publisher and Subscriber.
When you have clicked on the button that time you need to publish the messages.
Another side Azure functions have to consume the message of whatever you have published and inside that you need to decorate the email body and everything rest things required to send the email and send the mail to the users.
Sourabh DhimanPosted May 29, 2023, 10:59 AM
Sir it's not working.
Amit MohantyPosted May 29, 2023, 10:10 AM
Create a new class that inherits from BackgroundService. This class will contain the logic for sending the emails. Let's call it "EmailSenderService.cs":
In your Razor Page or Controller, inject the IHostedService interface and start the email sender service when the button is clicked.