locked
signalr/hubs not found at IIS! RRS feed

  • Question

  • User-1489574202 posted

    hello...

    i start learn signalr lib, i did simple chat app using ur manual:

    https://docs.microsoft.com/ru-ru/aspnet/signalr/overview/getting-started/tutorial-getting-started-with-signalr

    All works fine, BUT, then i publish app to IIS - its not work, brouser console says: signalr/hubs 404 not found!
    startup class

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



    hubs class

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



    index.html

    <html>
    <title>SignalR Simple Chat</title> <style type="text/css"> .container { background-color: #99CCFF; border: thick solid #808080; padding: 20px; margin: 20px; } </style>
    
    
    <script src="Scripts/jquery-1.6.4.min.js"></script> 
    <script src="Scripts/jquery.signalR-2.4.0.min.js"></script> 
    <script src="signalr/hubs"></script> 
    <script type="text/javascript"> 
    $(function () { 
    // Declare a proxy to reference the hub. 
    var chat = $.connection.chatHub; 
    // Create a function that the hub can call to broadcast messages. chat.client.broadcastMessage = function (name, message) { 
    // Html encode display name and message. 
    var encodedName = $('').text(name).html();
    var encodedMsg = $('').text(message).html(); 
    // Add the message to the page. 
    $('#discussion').append('' + encodedName + ':  ' + encodedMsg + ''); }; 
    // Get the user name and store it to prepend to messages. $('#displayname').val(prompt('Enter your name:', '')); 
    // Set initial focus to message input box. 
    $('#message').focus(); 
    // Start the connection. 
    $.connection.hub.start().done(function () { 
    $('#sendmessage').click(function () { 
    // Call the Send method on the hub. 
    chat.server.send($('#displayname').val(), $('#message').val()); 
    // Clear text box and reset focus for next comment. 
    $('#message').val('').focus(); 
    }); }); });
     </script> 

    and yes, i read this:

    https://docs.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/hubs-api-guide-javascript-client#genproxy

    all of this - not help:

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

    <script src="@Url.Content("~/signalr/hubs")"></script>  (this is not working like code)

    <script src='<%: ResolveClientUrl("~/signalr/hubs") %>'></script> (this is not working like code)

    Then i did server.js over signalr tools - signalr/hubs error was gone!

    But, i have new error:

    jquery-1.6.4.min.js:4

    GET http://localhost/signalr/negotiate?clientProtocol=2.0&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D&_=1544875075171

    404 (Not Found)

    At VS all woking fine, but at IIS - no =\

    SignalR installed over NuGet!
    .Net 4.7.2

    I need proxy, coz i not understand no proxy model, invoks, so many code....

    Help me, plz... =\

    Saturday, December 15, 2018 10:28 AM

All replies

  • User61956409 posted

    Hi colotoon,

    signalr/hubs 404 not found

    Please check ASP.NET SignalR FAQ "Why does signalr/hubs return 404 or Why do I get 'myhub' is undefined?".

    https://github.com/SignalR/SignalR/wiki/Faq#why-does-signalrhubs-return-404-or-why-do-i-get-myhub-is-undefined 

    Besides, if possible, please share a reproducible sample, so that we can test and troubleshoot the issue based on it.

    With Regards,

    Fei Han

    Monday, December 17, 2018 8:56 AM
  • User-1489574202 posted

    Hello

    1st of all u need understand easy thing: many ppl dont know asp.net, aspacialy IIS server(all uses Apache and PHP), so, u need make "how to start" maximaly informed about all!

    I used to get a working solution out of the box, in this case its working at VS but not working as published in IIS - its ur fault!

    U give link to wiki, ok, why i need goto wiki if im using "how to start" manual, mmm?? sry but its stupidness...

    So, show me plz, at siglanR manual guide, where need to put:

    RouteTable.Routes.MapHubs();

    to my code? mmm?? ofcouse i cant, its not exist, but need to app this thing to guide.

    or where i can see at manual this:

    If the above still doesn't work, make sure you have RAMMFAR set in your web.config:

    <div class="highlight highlight-text-xml">

    <configuration>
       <system.webServer>
            <modules runAllManagedModulesForAllRequests="true">
            </modules>
        </system.webServer>
    </configuration>

    mmm? no where... so sad...

    </div>



    Next, as i told, this is not works:
    <script type="text/javascript" src="~/signalr/hubs"></script>
    <script type="text/javascript" src="@Url.Content("~/signalr/hubs")"></script>
    <script type="text/javascript" src='<%= ResolveClientUrl("~/signalr/hubs") %>'></script>

    U ask me full code, ok, look here:
    https://docs.microsoft.com/en-us/aspnet/signalr/overview/getting-started/tutorial-getting-started-with-signalr

    try to follow this guide and build app, then publish it to IIS and u will see - its not working, so u guys need to fix "how to start" page!

    How i fix it? I just use self-host technics, only this is working for me, and im happy now,
    i not need to use this (#@#%) IIS and ASP tags (thanks Gods!)

    And 1 more thing, this published app dont working and in apache too.

    So, what u can to do - plz fix starting guide + sample code to 100% working code, ppl not need working only in VS, ppl need pubish apps,
    so plz make it working, ok?

    And TY for answer.
    Have a nice day.

    Monday, December 17, 2018 10:19 AM