Asynchronous send mail while action return content
In my web portal while somebody commented on a user's post i send email to post owner about it.
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SubmitComment(...)
{
Comment comment = new Comment {...
Mail.SendEmail(...);
return Content("OK");
}
When a comment submitted a post request with ajax and append the comment bottom of comment div. Because of sending email take relatively lo开发者_JAVA百科nger time response return late. So users begin to click submit link more than once. How can I return content while send email at background. Async Controller is a choice but the only where i need is this section.
Any recommendation, tutorial etc.
check this link, it describes how to send email async and catch message about sending status
http://msdn.microsoft.com/en-us/library/x5x13z6h.aspx#Y2052
and after in controller i would create an action that will be looking into session where you write data about sending email for particular user...
and of course reading it using ajax for response... the problem is the time may wary, so the question is .. is it the best way? p
精彩评论