-1

I have a vuejs application that is created in vue-cli3 and ASP.Net WebAPI w/SignalR created in .Net Framework 4.6.x

I'm having an issue connecting to SignalR and it's throwing an error "Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server".

As per this link: Detected a connection attempt error, i should use signalR instead of @aspnet/signalr. But when i try to use it, now it throws a jquery reference error. Should i really use Jquery here? I'm already stuck for 2 days on this.

My Vue Component:

import { HubConnectionBuilder, LogLevel } from 'signalr'
// import { HubConnectionBuilder, LogLevel } from '@aspnet/signalr' <--- I already tried this,same error
created() {
    const connection = new HubConnectionBuilder()
                  .withUrl('https://localhost:44356/chat-hub')
                  .configureLogging(LogLevel.Information)
                  .build()

    connection.start()
}

My Startup.cs

public void Configuration(IAppBuilder app)        
    {

        app.Map("/chat-hub",
            x =>
            {
                x.UseCors(CorsOptions.AllowAll);
                var hubConfig = new HubConfiguration
                {
                };

                x.RunSignalR(hubConfig);

            }
                            
        );

        app.MapSignalR();
        
    }

enter image description here

Phil
  • 157,677
  • 23
  • 242
  • 245
siobeh
  • 41
  • 1
  • 6
  • I searched for _"signalr no jquery"_ and found this ~ https://www.npmjs.com/package/signalr-no-jquery – Phil Aug 03 '20 at 06:42
  • @Phil, actually, i already tried that but still no success connecting to signalr. All resources available were always pointed to .Net Core – siobeh Aug 03 '20 at 06:48
  • @siobeh jquery is clearly listed as a dependency: https://www.npmjs.com/package/signalr?activeTab=dependencies – sommmen Aug 03 '20 at 06:55
  • Ah, sorry about that. I thought it said it was the .Net Framework version. I misread the description – Phil Aug 03 '20 at 22:13

1 Answers1

1

The problem is that you have used the ASP.NET Server component and the .NET Core Client.

You cannot mix those as they are not compatible.

Since you are building on .Net Framework 4.6.x and have the ASP.NET Server you need to download the ASP.NET Client which yes, does require JQuery.

If you don't want to use JQuery you will need to do the opposite and replace your server component with .NET Core 3.1 and keep (update) to the same .NET Core Client. Be aware that this is not a simple replacement, you will need to update many aspects of your code.

Frank M
  • 1,379
  • 9
  • 18