I am developing a chatting system on ASP.NET MVC using SignalR, I send to the front through the Clients.Caller.onConnected method a lot of messages and comments.
public override Task OnConnected() { var currentUser = HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(HttpContext.Current.User.Identity.GetUserId()); string id = Context.ConnectionId; string name = currentUser.ChatName; var messages = (from user in context.Users join message in context.Messages on user.Id equals message.UserId select new { user.ChatName, user.Photo, message.MessageText, message.Id}).ToList(); var comments = (from coment in context.Comments join user in context.Users on coment.UserId equals user.Id select new { user.ChatName, user.Photo, coment.CommentText, coment.Id, coment.MessageId }).ToList(); if (Users.Values.All(x => x != name)) { Users.Add(Context.ConnectionId, name); Clients.Caller.onConnected(id, name, Users, messages, comments);// Вот здесь вылазит exception Clients.AllExcept(id).onNewUserConnected(id, name); } return base.OnConnected(); } The first page load is normal. After rebooting from the onConnected method, I get an error - An exception of type 'System.OutOfMemoryException' occurred in the newtonsoft.Json.dll. Maybe someone came across, can somehow optimize json?
