2013-01-19 6 views

답변

0

당신은 두 가지 선택이있다.

b)는 비동기 컨트롤러를 SmtpClient.SendAsync() 전화 :

public class HomeController : AsynController 
{ 
    [HttpPost] 
    public void IndexAsync() 
    { 
     SmtpClient client = new SmtpClient(); 

     client.SendCompleted += (s,e) => 
     { 
      AsyncManager.Parameters["exception"] = e.Error; 
      AsyncManager.OutstandingOperations.Decrement(); 
     }; 

     AsyncManager.OutstandingOperations.Increment(); 

     client.Send(GetMessage()); 
    } 

    public void IndexCompleted(Exception exception) 
    { 
     if (exception != null) 
     { 
      ModelState.AddError("", "Email send failed"); 
      return View(); 
     } 
     else 
     { 
      return Redirect("Complete"); 
     } 
    } 
} 
+0

덕분에, 나는 B) 옵션을 연구합니다. – Alexander