I have an ASP.NET MVC 3 (.NET 4) web application.
I have an action method [HttpPost]that passes some data to the database.
Now, after this method finishes working with the repository, I want to perform a "background" task (think about auditing or sending emails, etc.), where I do not need the result (if there is no error, in which case I I will perform logging).
How can I run this task from my action method?
[HttpPost]
[Authorize]
public ActionResult Create(MyViewModel model)
{
if (ModelState.IsValid)
{
_repo.Save(model);
return RedirectToRoute("Somepage", new { id = model.id });
}
return View(model);
}
source
share