1
Answer

Developing a Chat Application using C# in ASP.Net

Photo of neeraj jain

neeraj jain

19y
2.3k
1
Hi,
i am building a Multi -User Chat Application using c# in ASP.Net
for the first 15 mins with 5-8 users it works fine
but after 15mins with more users andf more messages it becomes slow
i am using the ArrayList() to store the user messages, and the all messasges from the ArrayList are displayed on a webform using a RemoteScript function()
so every time the page is refreshed the RemoteScript function retriebves all the elements from the ArrayList and display them on the webpage

so can u help me, is it the right approach to do it.

Answers (1)

0
Photo of Dharmendra Singh
NA 179 34.6k 11y
you can use ViewBag for returning value and access through foreach on view,

Suppose I have a simple records
Id    Name    Status
1     Ram      true
2     Shyam   false

on model

public ABC
{
public int Id{get; set;}
public string Name{get; set;}
public bool Status{get; set;}
}

on Controller

List<ABC> items=new List<ABC>();
items.Add(new ABC{Id=1,Name="Ram",Status=true});
items.Add(new ABC{Id=2,Name="Shyam",Status=false});
ViewBag.dyProp = items;

you should use on view



@foreach(var item in ViewBag.dyProp)
{
if(item.Status)
{
// add approved values
}
}


@foreach(var item in ViewBag.dyProp)
{
if(!(item.Status))
{
// add not approved values
}
}