Önay Yalciner
Önay Yalciner

Reputation: 61

AspNetCore 2.2 Angular SignalR Negotiate always returns 404 Not found

I'm using

AspNetCore2.2 WebAppplication Angular CLI: 8.3.3 Node: 10.16.0 OS: win32 x64 Angular: 6.1.10

services.AddSignalR();
app.UseSignalR(config => {
  config.MapHub<NotificationHub>("/notify");
});
this.hubConnection.start().then(c => {
  console.log('connected');
});

startup.cs image 1

startup.cs image 2

Upvotes: 1

Views: 136

Answers (1)

Tony
Tony

Reputation: 20082

Check your code to see is there any code like below is missing

import * as signalR from "@aspnet/signalr";

const connection = new signalR.HubConnectionBuilder()
    .withUrl("/notify")
    .build();

connection.start().catch(err => document.write(err));

Update: Change the order of your code like this

app.UseSignalR(routes =>
{
    routes.MapHub<CmsCoreHub>("/cmscore");
});
app.UseMvc(routes =>
{
    routes.MapRoute(
        name: "default",
        template: "{controller=Home}/{action=Index}/{id?}");
});

Upvotes: 2

Related Questions