4
我有一個按鈕,用戶可以點擊某個按鈕來出價。每次投標,將最新的投標廣播給其他客戶。這就是我使用SignalR的原因。從SignalR Hub類中重定向用戶
現在,用戶需要有積分,如果他沒有積分,我想將他重定向到某處。
更明顯的方法使我失敗,所以任何建議都是值得歡迎的。
//Does the user have credits to spend?
if (user.LanceCreditBalance >= 1)
{
//populate the "ar" object and send it out to everybody.
var result = Json.Encode(ar);
Clients.addMessage(result);
}
else
{
//And this isn't working as expected. Doesn't redirect
//And causes a 302 error when viewing the Firebug console in Firefox.
HttpContext.Current.Response.Redirect(@"http://www.google.com");
}
上面的代碼都是在繼承自SignalR.Hub類的Chat類中。