1

When I am trying to connect to signalR (Asp.Net WebApi) through a seperate app (angular4) all locally, I get the following error:

http://127.0.0.1:50840/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22apihub%22%7D%5D&_=1503591726722. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:61679' is therefore not allowed access.

What was done here and here by doing the following:

public void Configuration(IAppBuilder app)
{
    app.Map("/signalr", map =>
    {
        map.UseCors(CorsOptions.AllowAll); //TODO: FIX THIS
        var hubConfiguration = new HubConfiguration()
        {
        };
        map.RunSignalR(hubConfiguration);
    });
}

But that still does not seem to work - any ideas? The Configuration gets hit on app startup. It seems simple, what am I missing? Thank you.

naspinski
  • 34,020
  • 36
  • 111
  • 167
  • Did you install the nugget `Install-Package Microsoft.AspNet.WebApi.Cors`...if not, then follow these instructions https://stackoverflow.com/questions/18619656/enable-cors-in-web-api-2#27360022 – Hackerman Aug 24 '17 at 16:39
  • No, but I did the more recent version which is explained here: https://learn.microsoft.com/en-us/aspnet/web-api/overview/security/enabling-cross-origin-requests-in-web-api – naspinski Aug 24 '17 at 18:47

0 Answers0