-1

I need a really simple way to execute a method asynchronously in an ASP.NET Web Forms C# website.

This method will be passed the email information (from, to, subject, body, etc) - and then send the email in the background - allowing page execution to complete without having to wait for the email to send.

This will be called from various places in the app - sometimes multiple times in a loop (where the delay is more of a problem and can even lead to timeouts).

What would be a nice lightweight way to do this?

I have tried WebAPI examples on the web, such as this: http://www.asp.net/web-api/overview/advanced/calling-a-web-api-from-a-net-client

But it gets stuck at 'await':

HttpResponseMessage response = await client.GetAsync("api/products/1");

and also seems overkill for what I need.

Thanks.

niico
  • 11,206
  • 23
  • 78
  • 161
  • possible duplicate of [Proper way to asynchronously send an email in ASP.NET... (am i doing it right?)](http://stackoverflow.com/questions/8747483/proper-way-to-asynchronously-send-an-email-in-asp-net-am-i-doing-it-right) – Lynn Crumbling Jan 09 '15 at 16:18
  • I have also now found this: http://hangfire.io - the above article looks at one way of doing it but there are others... – niico Jan 09 '15 at 18:21
  • Also found this now too, new in .net 4.5.2 QueueBackgroundWorkItem - http://www.hanselman.com/blog/HowToRunBackgroundTasksInASPNET.aspx – niico Jan 09 '15 at 18:22

1 Answers1

0

You can try send this e-mail with jQuery AJAX, then all of your problems are solved :D