0
どのような魂は、リアルタイムでデータをポーリングするために既存のmvcプロジェクトでsignalRを使用する方法を私に案内することができます。 サンプルコード:asp.net mvcのための信号のポーリングが必要
[コントローラ]
private ApplicationDbContext db = new ApplicationDbContext();
public PartialViewResult Chat(string people) // <---need to send real time data to partial
{
var model = new MessageVM()
{
sender = User.Identity.Name;,
messageList = db.messages.Where(x => x.receiver == people).ToList().Take(30)
};
return PartialView("_chat", model);
}
[ビュー]
@Ajax.ActionLink(item.name, "Chat", new { people = item.name }, new AjaxOptions()
{ HttpMethod = "GET", UpdateTargetId = "divChat", InsertionMode = InsertionMode.Replace })
<div id="divChat"></div> // <---this area need real-time messages data from controller.
はチャームとして機能します。 –