I have an ASP.NET MVC 3 (.NET 4) web application.
I have a [HttpPost]
action method which submit's some data to the database.
Now, after this method is finishing persisting to the repository, i wish to execute a "background" task (think auditing, or sending an email, etc), where i don't care about the result (unless an error occurs, in which case i'll perform logging).
How can/should i fire off this task from my action method?
[HttpPost]
[Authorize]
public ActionResult Create(MyViewModel model)
{
if (ModelState.IsValid)
{
_repo.Save(model);
// TODO: Fire off thread
return RedirectToRoute("Somepage", new { id = model.id });
}
return View(model);
}