c# - SendMailAsync sending very slow using async and await -


i have mvc controller called ajax post send email. have been trying use async/await pattern finding code below causes significant delay on sendmailasync(email) method. can explain why may case?

(note, smtpclient set in webconfig of ui project)

[httppost] public async task testmethod()     {         workflow.mailer rm = new workflow.mailer();         await rm.testemailbasic();      }  public async task testemailbasic()     {         var email = new mailmessage("website@test.me", "sadsad@test.com", "testing basic email", "hello world");          await sendemailasync(email);     }  public async task sendemailasync(mailmessage email)     {         using (var smtpclient = new smtpclient())         {             email.subject = "async test";             await smtpclient.sendmailasync(email);         }     } 

as explain on blog, async doesn't change http protocol. await in asp.net request "yields" asp.net threadpool, not browser. can return early or fire-and-forget approaches can dangerous because asp.net isn't designed it.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -