Closed shrayasr closed 2 months ago
Thanks for moving it over to this issue.
Yes! I totally agree ... and I ran into this exact scenario working on the reference docs. IIRC, I was working on updating the SignalR docs where hub config was shifting over based on the new extension methods. I couldn't find some optons but came to learn that they would appear in the next preview. Indeed, they arrived, and you can see the final result in this section ...
WRT to the auth question that you're asking, I might need to ping Jeremy to ask (or Steven Halter), as they're handling a certain amount of the auth updates this time around. However, I might be able to sort it out on my own.
I'm wrapping up a Blazor Forms article PR this morning, and I'll see if I can resolve this issue today. My plan in the non-auth cases is to cross-link to the new guidance (e.g., link to that SignalR options section from the Migration topic for SignalR hub config). We can't do that yet for auth options or setup because auth content hasn't been produced yet. What I'll do for anything I discover today on auth is call it out in the topic with examples there for the time being.
I'll get back to you later today.
@shrayasr ... I'm really happy that you opened this because I'm finding several sneaky bits π that are trying to get past me for migration coverage. I'll have a PR up soon, but I wanted to jump in here and ask you to try this for that option ...
app.MapBlazorHub(options => options.CloseOnAuthenticationExpiration = true);
Place it after your call to app.MapRazorComponents
.
~BTW ... I'm saying that I know it will work. That's just to get the ball rolling with what looks like might work π€π:smile:. I'm going to ask the PU to review my PR, which will include the MapBlazorHub
guidance that I'm adding along with other sneaky bits that I found to document. We'll get some feedback on the PR shortly after it goes up, and I'll ping you on the PR so that you can see what they say on review.~
No ... actually ... truly ... I think we'll be fine with the new section. I can't really hold up that doc, given that other doc authors might need to get in there at any point. I'll ask offline for the PU to put an ποΈ on that after it goes in.
... and BTW @shrayasr ... It's not an 8.0 thing, nor is it really "migration" guidance in the sense of upgrading a Blazor app. It's more a point of "migration" from other app types to Blazor. We just never had the options covered for MapBlazorHub
, which is definitely an oversight. I'm taking care of that now in the Fundamentals > SignalR doc. It won't appear in migration guidance, but I will ask on review after merging so as not to hold up the migration article for other updates if what I'm placing is reasonable. The migration guidance is receiving a nice update based on your ask for general options that will have a new call structure for Blazor Web Apps.
Hi @guardrex, I was fast asleep π΄ when all this action happened.
I will respond within a few hours. You are awesome. Thanks for getting to this so quickly β¨
Hi @guardrex
Yes! I totally agree ... and I ran into this exact scenario working on the reference docs. IIRC, I was working on updating the SignalR docs where hub config was shifting over based on the new extension methods. I couldn't find some optons but came to learn that they would appear in the next preview. Indeed, they arrived, and you can see the final result in this section ...
We are on NET8
and we are on the rc2
but we still don't see the .AddHubOptions
on AddInteractiveServerComponents
. Is this in some other assembly that needs to be added as a dependency? We have tried by doing using System;
as well. But no avail.
Edit: We were looking in the wrong place. We are able to use .AddHubOptions
on the builder. Sorry for the confusion.
I'm really happy that you opened this because I'm finding several sneaky bits π that are trying to get past me for migration coverage
I'm so glad that it helped in some way ππ½
app.MapBlazorHub(options => options.CloseOnAuthenticationExpiration = true);
Place it after your call to app.MapRazorComponents.
Unfortunately this didn't work. We are seeing the following error on the console:
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 GET http://localhost:5191/_blazor/initializers - - -
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1001]
2 candidate(s) found for the request path '/_blazor/initializers'
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1005]
Endpoint 'Blazor initializers' with route pattern '/_blazor/initializers/' is valid for the request path '/_blazor/initializers'
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1005]
Endpoint '(null)' with route pattern '/_blazor/initializers/' is valid for the request path '/_blazor/initializers'
dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[9]
Connection id "0HMUMNLG9R88S" completed keep alive response.
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 GET http://localhost:5191/_vs/browserLink - 200 - text/javascript;+charset=UTF-8 111.2111ms
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches:
Blazor initializers
at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ReportAmbiguity(Span`1 candidateState)
at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ProcessFinalCandidates(HttpContext httpContext, Span`1 candidateState)
at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.Select(HttpContext httpContext, Span`1 candidateState)
at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.MatchAsync(HttpContext httpContext)
at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[9]
Connection id "0HMUMNLG9R88R" completed keep alive response.
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 GET http://localhost:5191/_blazor/initializers - 500 - text/plain;+charset=utf-8 53.8392ms
And this errors in the browser console
GET http://localhost:5191/_blazor/initializers 500 (Internal Server Error)
(anonymous) @ blazor.web.js:1
(anonymous) @ blazor.web.js:1
startCircutIfNotStarted @ blazor.web.js:1
resolveRendererIdForDescriptor @ blazor.web.js:1
determinePendingOperation @ blazor.web.js:1
refreshRootComponents @ blazor.web.js:1
(anonymous) @ blazor.web.js:1
setTimeout (async)
rootComponentsMayRequireRefresh @ blazor.web.js:1
onDocumentUpdated @ blazor.web.js:1
Ds @ blazor.web.js:1
VM69:1 Uncaught (in promise) SyntaxError: Unexpected token 'M', "Microsoft."... is not valid JSON
await (async)
startCircutIfNotStarted @ blazor.web.js:1
resolveRendererIdForDescriptor @ blazor.web.js:1
determinePendingOperation @ blazor.web.js:1
refreshRootComponents @ blazor.web.js:1
(anonymous) @ blazor.web.js:1
setTimeout (async)
rootComponentsMayRequireRefresh @ blazor.web.js:1
onDocumentUpdated @ blazor.web.js:1
Ds @ blazor.web.js:1
aspnetcore-browser-refresh.js:260 WebSocket connection to 'wss://localhost:44332/BlazorNet8AuthTest/' failed:
(anonymous) @ aspnetcore-browser-refresh.js:260
getWebSocket @ aspnetcore-browser-refresh.js:257
(anonymous) @ aspnetcore-browser-refresh.js:16
aspnetcore-browser-refresh.js:19 WebSocket failed to connect.
We (@kalai-logicsoft and I) have made a sample project where we are able to replicate this error here for your reference: https://github.com/kalai-logicsoft/BlazorNet8AuthTest
We were wondering if this was because perhaps 2 hubs are being created and they are overlapping?
Let me know if you need more info on this from our end.
@shrayasr ... Open an issue for the product unit at ...
https://github.com/dotnet/aspnetcore/issues
Please add ...
cc: @guardrex https://github.com/dotnet/AspNetCore.Docs/issues/30843
... to the bottom of your opening comment so that I can follow along. I might re-open this for additional doc work depending on what they say.
Gotcha @guardrex. Doing it right away.
I have encountered exactly the same problem.
Have you found a solution?
As you're probably aware, we just had the .NET 8 release yesterday. AFAICT, they're still slammed with work related to the release. As Damian said in the .NET Conf keynote, this is probably the largest .NET release to date. There's no ETA for the PU issue, but I'm sure Surayya will get to it as soon as she can.
Same here
There's some new info provided by the PU issue. I'll take a look at adding some guidance (a point-in-time cross-link at least for 8.0 given that some kind of API is planned for .NET 9).
https://github.com/dotnet/aspnetcore/issues/51698#issuecomment-1984340954
Fixed by #33467.
Description
Allow me to set some context first. We are heavily invested in Blazor but we had to take a pause because of the incomplete auth story. I tweeted this out and @danroth27 kindly responded asking me to check if it was fixed in NET8. And it has been! So we're back on the Blazor bandwagon now.
However while we were upgrading, we saw the following suggestion
And we're kind of stuck here since our previous call to
MapBlazorHub
looked like this:And we're unable to find out where we should be moving the
CloseOnAuthenticationExpiration
call to?Is this something that you're able to help us with?
Cheers and thanks for all the great work!
Page URL
https://learn.microsoft.com/en-us/aspnet/core/migration/70-80?view=aspnetcore-7.0&tabs=visual-studio
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/migration/70-80.md
Document ID
534ab561-09c5-c33b-4394-0effba34d666
Article author
Rick-Anderson