1
我正在创建MVC应用程序聊天应用程序。我想要显示谁在线聊天。我如何显示它?如何使用Chatter Application MVC显示用户在线?
我喋喋不休控制器代码:
public ActionResult ChatterList(int ProjectId)
{
ReadCookieValue cookie = new ReadCookieValue();
clientId = cookie.readuserinfo().ClientId;
userId = cookie.readuserinfo().Id;
roleId = cookie.readuserinfo().RoleId;
ChatterViewModel model = new ChatterViewModel();
model.chattersList = Task.Run(() => _project.GetChatterList(ProjectId)).Result;
foreach (var item in model.chattersList)
{
item.CurrentUserId = userId;
}
model.newChatter = new ChatterModel();
model.newChatter.ProjectId = ProjectId;
model.newChatter.UserId = userId;
model.newChatter.UserName = cookie.readuserinfo().UserName;
return View("ProjectChatter", model);
}
public async Task<ActionResult> AddChatter(ChatterViewModel model)
{
if (model != null)
{
var obj = await _project.AddChatterList(model);
if (model.newChatter.ProjectId == 3)
{
return RedirectToAction("EbitDaReports");
}
}
return RedirectToAction("Reports");
}
,我使用Project ID查看代码看起来像
<div class="col-lg-6">
<div class="ibox-content">
<div class="chat-discussion">
<div class="ibox float-e-margins">
<div class="chat-element right">
<div class="row m-t-lg">
@if (Model.ProjectId > 0)
{
@Html.Action("ChatterList", "Projects", new { @ProjectId = Model.ProjectId })
}
</div>
</div>
</div>
</div>
</div>
</div>
我试图使用
<div class="row">
@if (HttpRuntime.Cache["ProjectId"] != null)
{
var loggedOnUsers = HttpRuntime.Cache["ProjectId"] as Dictionary<string, DateTime>;
if (loggedOnUsers != null)
{<div class="ProjectId">
}
<span> Online Users: </span>
</div>
}
}
</div>
我正在创建喋喋不休没有。我需要创建新的控制器?否则我可以覆盖现有的控制器?
我还是收到一个空白页@Shyju –
你有这段代码在你的视图中吗?你看到任何消息(“没有用户”?)。你的意思是空白页?完整的空白页面?没有什么?然后,您的网页中可能会出现其他一些错误。我建议你删除所有的代码,只是把这个,看看会发生什么 – Shyju
我已经厌倦了删除所有的代码把这个代码我得到空白页 –