.Net Core Console connect signalR 401 under windows authentication
See original GitHub issueDescribe the bug
When .net core signalR console app connect signalR server with Windows Authentication, receive 401.
To Reproduce
Steps to reproduce the behavior:
- Using this version of ASP.NET Core
netcoreapp2.1
with Windows Authentication enabled.
[Authorize]
public class TimeHub: Hub
{
public async Task UpdateTime(string message)
{
if (Clients != null)
{
await Clients?.All.SendAsync("ReceiveMessage", message);
}
}
}
- .Net Core Console App
class Program
{
static Action<string> OnReceivedAction = OnReceived;
static void Main(string[] args)
{
Console.WriteLine(WindowsIdentity.GetCurrent().Name);
//WindowsIdentity.RunImpersonated(WindowsIdentity.GetCurrent().AccessToken, Connect);
Connect();
Console.WriteLine("Hello World!");
Console.ReadLine();
}
private static async void Connect()
{
var hubConnectionBuilder = new HubConnectionBuilder();
var hubConnection = hubConnectionBuilder.WithUrl("http://localhost:61045/timeHub",options => {
options.UseDefaultCredentials = true;
}).Build();
await hubConnection.StartAsync();
await hubConnection.SendAsync("UpdateTime", $"From Client");
var on = hubConnection.On("ReceiveMessage", OnReceivedAction);
Console.WriteLine($"Client is Start");
Console.ReadLine();
on.Dispose();
await hubConnection.StopAsync();
}
static void OnReceived(string message)
{
Console.WriteLine($"{ message }");
}
}
Expected behavior
Console App connect signalR server correctly.
Current behavior
Receive error 401 at console app.
Update:
After making a test with https
and http
url in client signalr, it works with https url, it seems app.UseHttpsRedirection();
at server side fail to redirect the client credential while redirecting http to https.
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (9 by maintainers)
Top Results From Across the Web
iis - Asp.Net Core SignalR with Windows Authentication (401)
I am currently initializing the Hubs like this:Hub = new HubConnectionBuilder() .WithUrl(navMan.ToAbsoluteUri(hubPath), options => { options.
Read more >Authentication and authorization in ASP.NET Core SignalR
In a hub, authentication data can be accessed from the HubConnectionContext.User property. Authentication allows the hub to call methods on all ...
Read more >SignalR authorization not working out of the box in asp.net ...
This validation is done only when the connection is established. During the life of the connection, the server doesn't automatically revalidate ...
Read more >Guide for authenticating Azure SignalR Service clients
Learn how to implement your own authentication and integrate it with Azure SignalR Service by following the e2e example.
Read more >Authentication and Authorization for SignalR Hubs
NET client, such as a console app, which interacts with a hub that is limited to authenticated users, you can pass the authentication...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
https://docs.microsoft.com/en-us/aspnet/core/security/authentication/windowsauth?view=aspnetcore-2.2#visual-studio-settings-for-windows-and-anonymous-authentication
Closing this as we haven’t heard from you in a little while. Please feel free to comment if you’re able to get the information we’re looking for and we can reopen the issue if we’re able to identify the problem.