Hi,
I am trying to develop a simple chat application in ASP.Net
i am using signalR.
the messages are not getting printed on the screen
Below is the .aspx code
- <head id="Head1" runat="server">
- <title></title>
- </head>
- <body>
- <form id="frmHome" runat="server">
- <div>
- <ul id="ulInbox">
- <li><span id="lblName">Name:</span> <span id="lblMessage">Message</span></li>
- </ul>
- <ul>
- <li>
- <input type="text" id="txtMessage" value="" />
- <input type="button" id="btnSend" value="Send" />
- <input type="hidden" id="txtName" />
- </li>
- </ul>
- </div>
- </form>
- <script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script>
- <script src="Scripts/jquery.signalR-1.0.1.min.js" type="text/javascript"></script>
- <script src="signalr/hubs" type="text/javascript"></script>
- <script type="text/javascript">
- $(function () {
-
- var chat = $.connection.chatHub;
-
- $('#txtName').val(prompt('Enter your name:', ''));
-
- chat.client.sendMessage = function (name, message) {
- var username = $('<div />').text(name).html();
- var chatMessage = $('<div />').text(message).html();
- $('#ulInbox').append('<li>' + username + ': ' + chatMessage + '</li>');
- };
-
- $.connection.hub.start().done(function ()
- {
- $('#btnSend').click(function ()
- {
-
- chat.server.send($('#txtName').val(), $('#txtMessage').val());
- $('#txtMessage').val('');
- });
- });
- });
- </script>
- </body>
- </html>
This method should be called....but is is not getting called
- public class ChatHub : Hub
- {
- public void Send(string name, string message)
- {
- Clients.All.sendMessage(name, message);
- }
- }
- public class Global : System.Web.HttpApplication
- {
- void Application_Start(object sender, EventArgs e)
- {
-
- RouteTable.Routes.MapHubs();
- }
- }
Thank you