You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Blazor client-side app that attaches to the following;
[Authorize]
public class StockTickerHub : Hub
{
}
I use Cookie Auth. When I login the blazor client attaches just fine.
When I don't login I get the following client-side exception;
System.IO.InvalidDataException: Invalid negotiation response received. ---> System.Text.Json.JsonReaderException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException (System.Text.Json.Utf8JsonReader& json, System.Text.Json.ExceptionResource resource, System.Byte nextByte, System.ReadOnlySpan`1[T] bytes) <0x3075f70 + 0x00020> in <filename unknown>:0
at System.Text.Json.Utf8JsonReader.Read () <0x2db66f0 + 0x0005c> in <filename unknown>:0
at Microsoft.AspNetCore.Internal.SystemTextJsonExtensions.CheckRead (System.Text.Json.Utf8JsonReader& reader) <0x3075e60 + 0x00002> in <filename unknown>:0
at Microsoft.AspNetCore.Http.Connections.NegotiateProtocol.ParseResponse (System.ReadOnlySpan`1[T] content) <0x3075898 + 0x00034> in <filename unknown>:0
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Http.Connections.NegotiateProtocol.ParseResponse (System.ReadOnlySpan`1[T] content) <0x3075898 + 0x0044c> in <filename unknown>:0
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.NegotiateAsync (System.Uri url, System.Net.Http.HttpClient httpClient, Microsoft.Extensions.Logging.ILogger logger, System.Threading.CancellationToken cancellationToken) <0x2fb6260 + 0x003d4> in <filename unknown>:0
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.GetNegotiationResponseAsync (System.Uri uri, System.Threading.CancellationToken cancellationToken) <0x2fba2b8 + 0x000dc> in <filename unknown>:0
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.SelectAndStartTransport (Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) <0x2fb8730 + 0x00258> in <filename unknown>:0
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsyncCore (Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) <0x2f90750 + 0x001e2> in <filename unknown>:0
at System.Threading.Tasks.ForceAsyncAwaiter.GetResult () <0x30df0c8 + 0x00026> in <filename unknown>:0
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsync (Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) <0x2f84928 + 0x0010a> in <filename unknown>:0
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync (System.Net.EndPoint endPoint, System.Threading.CancellationToken cancellationToken) <0x2f1f2f0 + 0x001be> in <filename unknown>:0
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync (System.Net.EndPoint endPoint, System.Threading.CancellationToken cancellationToken) <0x2f1f2f0 + 0x002c8> in <filename unknown>:0
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <0x30e1450 + 0x00034> in <filename unknown>:0
at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncCore (System.Threading.CancellationToken cancellationToken) <0x2f18f40 + 0x00110> in <filename unknown>:0
at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncInner (System.Threading.CancellationToken cancellationToken) <0x2eff078 + 0x002da> in <filename unknown>:0
at System.Threading.Tasks.ForceAsyncAwaiter.GetResult () <0x30e1668 + 0x00026> in <filename unknown>:0
at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsync (System.Threading.CancellationToken cancellationToken) <0x2efdf48 + 0x0010e> in <filename unknown>:0
at BlazorAppRealTime.Pages.Stocks.OnInitializedAsync () [0x000d6] in C:\work\github\fluffy-bunny\asp.net-inmemory-identity-blazor\src\BlazorAppRealTime\Pages\Stocks.razor:57
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync () <0x2bf9318 + 0x0013a> in <filename unknown>:0
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask (System.Threading.Tasks.Task taskToHandle) <0x2e46478 + 0x000b6> in <filename unknown>:0
This is caused by me having my StockTickerHub requiring [Authorize]
Is there a way for me to know for sure that this was because of Authorization vs something else?
On my end I can catch and redirect to login, but I don't like guessing as to what the problem was. System.IO.InvalidDataException is too vague.
I guess I could just blindly catch it and do a good ole REST call that will give me back a 401 and react properly to that.
I still need to figure out how to kill the signalR connection similar to cookie auth expiration, which doesn't happen here if the client just sits on the signalR connection. Any pointers on this would be great.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a Blazor client-side app that attaches to the following;
I use Cookie Auth. When I login the blazor client attaches just fine.
When I don't login I get the following client-side exception;
This is caused by me having my
StockTickerHub
requiring[Authorize]
Is there a way for me to know for sure that this was because of
Authorization
vssomething else
?On my end I can catch and redirect to login, but I don't like guessing as to what the problem was.
System.IO.InvalidDataException
is too vague.I guess I could just blindly catch it and do a good ole REST call that will give me back a 401 and react properly to that.
I still need to figure out how to kill the signalR connection similar to cookie auth expiration, which doesn't happen here if the client just sits on the signalR connection. Any pointers on this would be great.
Beta Was this translation helpful? Give feedback.
All reactions