Click here to Skip to main content
15,886,077 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
i created chat simple chat application by using sessions in my system ,when i open my browser and login i goes to my chat page ,when i type and press send button text goes to chating box it's fine but when i open new browser and request same url loading fresh not showing any history chat ............

doubts:-

1.for suppose i hosted this one on server when several members login and different machines and they will chat properly(they will see the who is typing and what they are typing)..it's work or not...........

2.if it is not work how to solve this one....
Posted

Is it a group chat you're looking to implement? The session is tied to the user and each user (browser instance) has their own session so anything in user A's session can't be seen by user B. If you want all users to see the chat history then use the Application object rather than the Session. There is only one Application object and it is common across all users. In terms of coding there is no real difference, but make sure you understand application locking (google "asp.net locking the application object")
 
Share this answer
 
Comments
Member 10458660 23-Mar-15 1:28am    
Thank you.............very much
Santosh K. Tripathi 23-Mar-15 8:36am    
if you like answer, you should accept it as solution. The person who gave the answer feel good and he will give answer to other's questions also.
Santosh K. Tripathi 23-Mar-15 8:33am    
thanks F-ES Sitecore for reply.
today i come to know one new thing. +5 from me.
Zoltán Zörgő 23-Mar-15 14:07pm    
Not quite correct: the Application instance is not guaranteed to be common, as there can be many instances at any point in time. But the Application class is common. Thus if you use static members, you can communicate between instances, altrought you need to care about thread-safety as you also noted.
see: http://www.codeproject.com/Articles/73728/ASP-NET-Application-and-Page-Life-Cycle and https://support2.microsoft.com/default.aspx?scid=kb;en-us;Q312607.

Still, using this for a chat application is not quite the best approach.
F-ES Sitecore 23-Mar-15 15:27pm    
When I said "Application" I was referring to the ApplicationState object that you access via the "Application" property. I wasn't referring to the HttpApplication.

Application["MyData"] = "hello";
Do you know why you got downvoted?
1) Because your question can't be answered. Actually it can be: it all depends on you, on how and what you code. Of course a chat application using asp.net and sql server can be made. There are many successfull implementations out there. If you want to know you can do it? Well, if you ask such questions... I have my doubts...
2) And we got to the second cause: what is stopping you to loog for one of them, consult the code and learn from it? Lazyness? Or is goole not available at your place? Just one of them right here, at CP:
ASP/SQL Server Based Chat program[^]
 
Share this answer
 
v2
Comments
Member 10458660 23-Mar-15 1:31am    
just i am clearing from experts because they know what happen.... i am not interested on downvoting or upvoting..if any one know the answer they will give reply otherwise don't.........google is there all our requirement question no there..
Zoltán Zörgő 23-Mar-15 14:02pm    
"google is there all our requirement question no there" neither are they here, as you haven't posted any.
Anyway, the answer you have got is not correct...
F-ES Sitecore 23-Mar-15 16:51pm    
The reason that article talks about classic ASP is because it is 15 years old and is about .net 1.0, when migrating from classic ASP was a major concern. The Application is still kicking around though. I agree static classes would be better, or using Cache would be better still as you can control expiry. Or even storing permanent in a database. However the OP is clearly new to asp.net and just learning, and as he is familiar with the Session I thought moving to the Application would be the path of least resistance, even if it isn't the most ideal solution. I was targeting my answer to the ability of the questioner.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900