samedi 29 août 2015

Error: An asynchronous module or handler completed while an asynchronous operation was still pending

I have a Controller Action method to Save user Details like below.

public async Task<ActionResult> SaveUser(ViewModel.VM_CreateUser user)
{
    var result = await _user.Save(userDetails);
    return Json(new { Success = String.IsNullOrEmpty(result) });
}

So far there is no issue in above 4 lines function.

public async Task<ActionResult> SaveUser(ViewModel.VM_CreateUser user)
{
    var result = await _user.Save(userDetails);
    new MailController().CreateUser(user.userDetails); //<==This is problem line of code.
}

and Below is my Mail Controller.

public class MailController : MailerBase
{
    public void CreateUser(ViewModel.VM_User user)
    {
        To.Add(user.EmailAddress);
        From = System.Configuration.ConfigurationManager.AppSettings["emailSender"];
        Subject = "Hi";
        Email("CreateUser", user).DeliverAsync();
    }
}

in the above code, I am facing problem when I execute the Email Sending code. I get below error message.

An asynchronous module or handler completed while an asynchronous operation was still pending

Please suggest the corrective action !!

Aucun commentaire:

Enregistrer un commentaire