Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • duyquy301 9 posts 78 karma points
    Aug 07, 2015 @ 04:53
    duyquy301
    0

    SignalR Chat

    Hi All.

    I'm using umbraco v7.0. I would build project chat with SignalR microsoft. The structure of project: App(web umbraco) -View include js files -

    <script src="/Scripts/jquery.signalR-2.2.0.min.js"></script>
    <script src="/signalr/hubs"></script>
    MVC(build controller) - ChatHub file

      public class ChatHub : Hub
    {
        public void Send(string name, string message)
        {
            // Call the broadcastMessage method to update clients.
            Clients.All.broadcastMessage(name, message);
        }
    }
    

    -Startup file public class Startup { public void Configuration(IAppBuilder app) { // Any connection or hub wire up and configuration should go here app.MapSignalR(); }
    }

    When i run page : $(function () { // Reference the auto-generated proxy for the hub.
    var chat = $.connection.chatHub; }); error:

    <script src="/signalr/hubs"></script>

    404 not found.

    Please help me fix this issue.

    Thanks

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Aug 07, 2015 @ 11:50
    Alex Skrypnyk
    0

    Hi,

    Do you have a Configuration method?

    [assembly: OwinStartup(typeof(SignalRProgress.Startup))]
    namespace SignalRProgress
    {
        public class Startup
        {
            public void Configuration(IAppBuilder app)
            {
                // Any connection or hub wire up and configuration should go here
                app.MapSignalR();
            }
        }
    }
    
  • duyquy301 9 posts 78 karma points
    Aug 12, 2015 @ 10:52
    duyquy301
    0

    Hi Alex Skrypnyk

    I have init code

    app.MapSignalR();

    but it is not working.

    error :

    <script src="~/signalr/hubs"></script>

    404 not found

  • Marcel van Helmont 68 posts 259 karma points c-trib
    Aug 12, 2015 @ 11:10
  • duyquy301 9 posts 78 karma points
    Aug 14, 2015 @ 03:29
    duyquy301
    0

    Hi Marcel van Helmont

    Thanks

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Aug 12, 2015 @ 11:38
    Alex Skrypnyk
    2

    Did you add '~/signalr/hubs' path to the umbraco reserved paths ?

    <add key="umbracoReservedPaths" value="/umbraco/,/signalr/" />
    

    Thanks, Alex

  • duyquy301 9 posts 78 karma points
    Aug 13, 2015 @ 09:36
    duyquy301
    0

    Hi Alex Skrypnyk

    Yep, i have added umbracoReservedPaths

    Thanks

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Aug 13, 2015 @ 10:39
    Alex Skrypnyk
    0

    Hi,

    What error do you have now ?

    Thanks

  • duyquy301 9 posts 78 karma points
    Aug 14, 2015 @ 02:44
    duyquy301
    0

    Hi Alex Skrypnyk

    Now i have errror

    http://localhost:282/signalr/hubs/ 400 (Bad request)

    Thanks

  • duyquy301 9 posts 78 karma points
    Aug 13, 2015 @ 10:41
    duyquy301
    0

    this is error http://localhost:282/signalr/hubs/ 404 (Not Found)

    Thanks

  • duyquy301 9 posts 78 karma points
    Aug 14, 2015 @ 03:29
    duyquy301
    0

    Hi Alex Skrypnyk

    It is working.

    Thanks

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Aug 14, 2015 @ 07:34
    Alex Skrypnyk
    0

    Hi,

    What was the problem ?

  • Comment author was deleted

    Oct 01, 2015 @ 08:14

    Would also love to know what the problem was and how it was resolved since I get the same behaviour on a 7.3.0 site (working fine on 7.2.8)

  • Danny Drogt 10 posts 121 karma points c-trib
    Oct 22, 2015 @ 22:19
    Danny Drogt
    11

    I had the same problem with 7.3.0, got it solved now. As far as I could tell it has to do with the fact that Umbraco uses OWIN since 7.3.0. See web.config, it has an entry

    <add key="owin:appStartup" value="UmbracoDefaultOwinStartup" />
    

    Before 7.2.8 it didn't use this. You probably have your Startup.cs class to register the use of SignalR? The startup class doesn't get called in the new 7.3.0 scenario. To fix this, create a class that inherits from UmbracoDefaultOwinStartup and add the SignalR usage. Change the web.config entry to the friendly name you give your OWIN class.

    <add key="owin:appStartup" value="TestStartup" />
    

    With my Startup.cs looking like this:

    using System;
    using System.Threading.Tasks;
    using Microsoft.Owin;
    using Owin;
    using Umbraco.Web;
    
    [assembly: OwinStartup("TestStartup", typeof(WebApplication1.Startup))]
    
    namespace WebApplication1
    {
        public class Startup : UmbracoDefaultOwinStartup
        {
            public override void Configuration(IAppBuilder app)
            {
                base.Configuration(app);
                app.MapSignalR();
            }
        }
    }
    

    HTH

Please Sign in or register to post replies

Write your reply to:

Draft