Trường Giang Vũ Trường Giang Vũ - 1 year ago 104
C# Question

Where messages are stored in SignalR

I'm new to SignalR, but I've read and done some of SignalR tutorials. I wonder where messages are stored in SignalR. If I integrate some authentications and build a chat app, where messages are stored? If I need a SQL database, how can I design it to save users' conversations?

Answer Source

Your messages are going to store in database if you have connected your app to a database. If not then it's going to be temp save in a local server which could be your machine and will loose the data when you reboot it.

Once you've installed the SQL database you can save the messages in it.

For Eg:

 $('#btnSendMsg').click(function () {
   var msg = $("#textMessage").val();

   if (msg.length > 0) {

       var UserName = $('#UserName').val();
        objHub.server.saveMessagetoDB(UserName, msg);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download