0

比如有一个Register按钮,当按钮被点击时,它会向Action Register发送一个ajax请求做数据库处理,然后发送验证邮件。

$.ajax({
    url: "/Register",
    type: 'POST',
    error: function(xhr) {},
    success: function(data) {
       //after success, change the button color                   
    }
});

[HttpPost]
public ActionResult Register() { 
     //database processing
     ......
    //send email 
    //(this step takes long period of time, the button wait for long time to change the color, how can i solve this issue?)
}
4

1 回答 1

0

当您从网页调用长时间处理操作时,您不想等待它完成。所以你要做的就是将长处理任务添加到队列中并返回。您可以使用 MSMQ 之类的东西,也可以自己构建简单的队列机制,即在表中插入要发送的电子邮件的记录,然后让其他进程查看该表并发送电子邮件...

于 2012-12-08T13:54:24.450 回答