问题
We recently updated a WPF app and all of its NuGet dependencies to .NET 4.5.2 and find that some users are receiving HTTP 401 Unauthorized errors from SignalR. The is using Windows Authentication via PrincipalUserIdProvider.
I receive the 401 error on the first POST to SignalR after connecting to SignalR but here are many reasons why this is a strange issue:
- It works when I have Fiddler running
- It works when I run the app on Citrix
- It works when I run the app with a Run As on another person's PC
- It works when I log in to someone else's PC
- It works when I run an older version of the client that is on .NET 4.0 (still connecting to the same server)
- It works in QA (but doesn't everything?)
- It works when someone else uses my PC to run the app
The issue only occurs for a small fraction of user/machine combinations, but for those setups the 401 occurs 100% of the time. Occurs on both a Win7 and Win8.1 client. Server does not have websockets installed.
Any suggestions on what could possibly be the issue?
回答1:
I have no idea why, but referencing the net40 copy of the SignalR client dll instead of the net45 copy resolves the issue.
I deleted the reference to Microsoft.AspNet.SignalR.Client.dll and readded the reference using the net40 dll in my NuGet packages folder: Microsoft.AspNet.SignalR.Client.2.2.0\lib\net40\Microsoft.AspNet.SignalR.Client.dll
来源:https://stackoverflow.com/questions/31031302/signalr-net45-gives-401-unauthorized-on-specific-user-machine-combinations