title: SignalR in ASP.Net Core 401 Unauthorized
body: <p>I have a small problem with my UWP app. First, the UWP app has the following capabilities:</p>
  
  <ul>
  <li>Enterprise Authentication</li>
  <li>Shared user certificates</li>
  <li>Private Networks</li>
  <li>User Account Information</li>
  </ul>
  
  <p>Now I want to connect to a SignalR-Hub in an ASP.NET Core 2.1 Web API. The hub looks like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>using Microsoft.AspNetCore.Authorization;
  using Microsoft.AspNetCore.SignalR;
  
  namespace Test.Namespace
  {
      [Authorize]
      public class SyncHub : Hub
      {
          public void SendUpdate()
          {
              Clients.All.SendAsync("Update");
          }
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>And this is my Startup.cs:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>using Microsoft.AspNetCore.Builder;
  using Microsoft.AspNetCore.Hosting;
  using Microsoft.AspNetCore.Mvc;
  using Microsoft.AspNetCore.SignalR;
  using Microsoft.Extensions.Configuration;
  using Microsoft.Extensions.DependencyInjection;
  
  namespace Test.Namespace
  {
      public class Startup
      {
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
          }
  
          public IConfiguration Configuration { get; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
  
              services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
  
              services.AddSignalR();
              services.AddSingleton&lt;IUserIdProvider, NameUserIdProvider&gt;();
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IHostingEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseHsts();
              }
  
              app.UseHttpsRedirection();
  
              app.UseSignalR(routes =&gt;
              {
                  routes.MapHub&lt;SyncHub&gt;("/syncHub");
              });
              app.UseMvc();
          }
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>The whole API runs on an IIS with Windows Authentication configured. The Active Directory runs on the same machine.</p>
  
  <p>And this is how my UWP app calls the Service:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>            HubConnection connection = new HubConnectionBuilder().WithUrl("http://Server:81/syncHub", options =&gt; {
                  options.UseDefaultCredentials = true;
              }).Build();
              await connection.StartAsync();</code></pre>
  </div>
  </div>
  </p>
  
  <p>This call always throws a 401.</p>
  
  <p>What am I doing wrong? I work on this Problem for more than a week now and I can't figure out why it is not working.</p>
  
  <p>Thanks to all who will help me :)</p>
  
  <p><strong>Edit</strong>: So I tried a few thinks today and found out, that this is not a problem of SignalR itself.I created a ASP.NET Core console app with the exact same call and everything works fine. It also works when I hardcode the credentials in the UWP app. It only doesn't work when I use "UseDefaultCredentials" in UWP. I am completly clueless. I have rechecked the capabilities but this doesn't help either.</p>