locked
Problems Finding Hub RRS feed

  • Question

  • User1122355199 posted

    Hello everyone and thanks for your help in advance.  I'm trying to develop a SignalR application but am running into problems getting the paths correct.  I have a hub that looks like:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Microsoft.AspNet.SignalR;
    using System.Data.SqlClient;
    using System.Data;
    using Microsoft.AspNet.SignalR.Hubs;
    
    namespace ChatExample.Hubs
    {
        [HubName("TwilioSMS")]
        public class TwilioSMS : Hub
        {
    
            //
            public IEnumerable<tbl_Log_InboundSMSMessages> GetAllMessages()
            {
                //
                // Do database stuff to create list and SQL Notification
                return SMSMessages;
    
            }
    
    
        }
    }

    The jQuery on the page:

        <script src="~/Scripts/jquery-1.10.2.js"></script>
        <script src="~/Scripts/jquery.signalR-2.3.0.js"></script>
        <!--Reference the autogenerated SignalR hub script. -->
        <script src="/signalr/hubs"></script>
        <script type="text/javascript">
        $(function () {
            // Declare a proxy to reference the hub.
            var notifications = $.connection.TwilioSMS;
    
            //debugger;
            // Create a function that the hub can call to broadcast messages.
            notifications.client.updateMessages = function () { getAllMessages()
    
            };
            // Start the connection.
            $.connection.hub.start().done(function () {
                alert("connection started")
                getAllMessages();            
            }).fail(function (e) {
                alert(e);
            });
        });
    
        function getAllMessages()
        {
            var tbl = $('#messagesTable');
            $.ajax({
                url: '/TwilioSMS/GetAllMessages',
                contentType: 'application/html ; charset:utf-8',
                type: 'GET',
                dataType: 'html'
            }).success(function (result) {
                tbl.empty().append(result);
            }).error(function () {
    
            });
        }
        </script>

    I am receiving the error "jquery-1.10.2.js:8720 GET http://localhost:51695/TwilioSMS/GetAllMessages 404 (Not Found)".  I'm not sure what the problem is.  Any help would be appreciated.

    Thursday, December 13, 2018 2:29 AM

All replies