Loading

SmtpException: Failure sending mail. ---> System.InvalidOperationException: Asynchronous operations are not allowed in this context.

问题如下 

System.Net.Mail.SmtpException: Failure sending mail. 
---> System.InvalidOperationException: Asynchronous operations are not allowed
in this context. Page starting an asynchronous operation has to
have the Async attribute set to true and an asynchronous op

 甭理他什么页面需要异步,直接把发邮件代码仍到 Task.Run() 里面执行妥妥的完事儿 :

 

Task.Run(()=> {

SendMailCodes();

});

  

 

posted @ 2020-05-21 16:31  韩严重  阅读(256)  评论(0编辑  收藏  举报