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.
는 매력으로 작동합니다. –