2012-12-08 37 views
0

例如,有一個註冊按鈕,點擊該按鈕時,它會發送一個Ajax請求的動作寄存器做數據庫的處理,然後發送確認電子郵件。ASP.NET MVC3 HttpPost + jQuery的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?) 
} 

回答

0

當您從網頁調用一個長處理操作時,您不想等待它完成。所以你要做的是將長處理任務添加到隊列中並返回。你可以使用像MSMQ或者你可以建立簡單的隊列機制自己,即插入你想要在一個表中發送,然後有一些其他進程看該表併發送電子郵件的電子郵件記錄......

+0

謝謝,MSMQ是解決方案! – Hekensi