Call to MapSignalR raises protocol error

this is a follow-up to my previous question here.

MVC - problem with binding to another controller / action

as you can see I eventually got my view from another controller to display in a new tab for it to work. until I installed SignalR. a simple version using this tutorial as a guide.

http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr-and-mvc

the tutorial did a great job after following the steps to create the project. the only thing I had to do to get it working was to change the jquery version of the jquery signalr file to the latest (this was one thing I didn't have because the tutorial was written in old VS 2012).

anyway, after doing the same for my site, I now get an error when I click the link for / SignalR / SRStart (new tab).

Protocol error: Unknown transport

Playing around, I found that this only happens after calling app.MapSignalR () in the startup.cs file. can't figure out why as the tutorial I followed worked fine if it had nothing to do with navigating to another controller from that link. it's in the SRStart view that I put all of the signalr connection code and callback function, but I don't think it ever got there since the page doesn't even load.

this is my code.

startup.cs

public partial class Startup
{
    public void Configuration(IAppBuilder app)
    {
        ConfigureAuth(app);
        app.MapSignalR();
    }
}

      

Concentrator

public class SRHub : Hub
{
    public void Send(string message)
    {
        // Call the addNewMessageToPage method to update clients.
        var conn = GlobalHost.ConnectionManager.GetHubContext<SRHub>();
        conn.Clients.All.addNewMessageToPage(message);
        //Clients.All.addNewMessageToPage(message);
    }
}

      

javascript in SRStart.cshtml

    $(function () {
        // Reference the auto-generated proxy for the hub.
        var conn = $.connection.sRHub;
        // Create a function that the hub can call back to display messages.
        conn.client.addNewMessageToPage = function (message) {
            if (!message.contains('[EOF]')) {
                populateStreamDialog(message);
            }
        };

        $.connection.hub.start()
            .done(function () {

            });
    });

      

any help would be appreciated.

+3


source to share


1 answer


I was able to replicate the error. The problem is that /SignalR

is the route used by SignalR itself. Using a named MVC controller SignalRController

, there is now a conflict between SignalR and MVC causing the error. Just rename your MVC controller SignalRController

(and the folder containing its views) to something else ...



+1


source







All Articles