SignalR asks for credentials for authentication using 401

I have a .Net 4.5 site with MVC, web API and SignalR and using Windows Authentication. Everything works fine until I add hubs to my HTML with:

@Scripts.Render("~/signalr/hubs")

With this line in place, about 1/3 of the time, when I press F5 to refresh the page, I get a username and password prompt before loading the page. This sometimes affects only the hub, in other cases it affects some types of MVC, and sometimes the entire page. I have this in mine Startup.cs:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.SetDefaultSignInAsAuthenticationType(NtlmAuthenticationDefaults.AuthenticationType);
        app.UseNtlmAuthentication();
        app.MapSignalR(new HubConfiguration()
        {
            EnableDetailedErrors = true,
            EnableJSONP = true
        });
    }
}

In web.config:

<authentication mode="Windows" />
<authorization>
    <deny users="?" />
</authorization>

I noticed in Fiddler that the hubs.js request has a header Authorization: Negotiate .... Immediately after the second request, also for hub.js, s Authorization: Negotiate ..., but the hash is different.

- , ? ​​ . , SignalR. , , - JS.

  • SignalR: 2.2.0
  • Microsoft.Owin.Host.SystemWeb: 3.0.1
  • Pysco68.Owin.Authentication.Ntlm: 1.0.2

Chrome. IE .

: , Fiddler. , : MVC, SignalR Fiddler Ntlm? , . Fiddler, . ?

+4
1

, . , web.config.

- fiddlers Automatically Authenticate options .

+1

Source: https://habr.com/ru/post/1619110/


All Articles