Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dotnet 9.0 scaffolding no longer works - errors when doing NavigationManager.NavigateTo in Create.razor #58951

Closed
1 task done
coderdnewbie opened this issue Nov 14, 2024 · 12 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components Docs This issue tracks updating documentation

Comments

@coderdnewbie
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Perform the Dan Roth tutorial in https://www.youtube.com/watch?v=ZN-CcfEY3Z8

At 5:39 when the Create button is pressed, a failure happens in

NavigationManager.NavigateTo("/movies");

This is the failure in VS2022 17.12:

Microsoft.AspNetCore.Components.NavigationException
HResult=0x80131500
Message=Exception_WasThrown
Source=Microsoft.AspNetCore.Components.Server
StackTrace:
at Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.NavigateToCore(String uri, NavigationOptions options)
at Microsoft.AspNetCore.Components.NavigationManager.NavigateToCore(String uri, Boolean forceLoad)
at Microsoft.AspNetCore.Components.NavigationManager.NavigateTo(String uri, Boolean forceLoad, Boolean replace)
at BlazorMovieCRUDDemo.Components.Pages.MoviePages.Create.d__5.MoveNext() in C:\Users\ajayt\Desktop\Upgrade to dotnet 9 GA\BlazorMovieCRUDDemo\BlazorMovieCRUDDemo\Components\Pages\MoviePages\Create.razor:line 58
at Microsoft.AspNetCore.Components.ComponentBase.d__30.MoveNext()

This is from the autogenerated scaffolding performed exactly as Dan does it.

This used to work in dotnet 8.0, but now fails in dotnet 9.0.

Additionally, my dotnet 8.0 project when upgraded to dotnet 9.0 fails here as well.

Expected Behavior

I expect this to work as it did in dotnet 8.0

Steps To Reproduce

Perform the Dan Roth tutorial in https://www.youtube.com/watch?v=ZN-CcfEY3Z8

At 5:39 when the Create button is pressed, a failure happens in

NavigationManager.NavigateTo("/movies");

This is scaffolded code in Create.razor in the MoviePages subfolder.

Exceptions (if any)

This is the failure in VS2022 17.12:

Microsoft.AspNetCore.Components.NavigationException
HResult=0x80131500
Message=Exception_WasThrown
Source=Microsoft.AspNetCore.Components.Server
StackTrace:
at Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.NavigateToCore(String uri, NavigationOptions options)
at Microsoft.AspNetCore.Components.NavigationManager.NavigateToCore(String uri, Boolean forceLoad)
at Microsoft.AspNetCore.Components.NavigationManager.NavigateTo(String uri, Boolean forceLoad, Boolean replace)
at BlazorMovieCRUDDemo.Components.Pages.MoviePages.Create.d__5.MoveNext() in C:\Users\ajayt\Desktop\Upgrade to dotnet 9 GA\BlazorMovieCRUDDemo\BlazorMovieCRUDDemo\Components\Pages\MoviePages\Create.razor:line 58
at Microsoft.AspNetCore.Components.ComponentBase.d__30.MoveNext()

.NET Version

9.0.0

Anything else?

Image

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Nov 14, 2024
@coderdnewbie
Copy link
Author

Additional Information, which might help.

Even though this was selected as InteractiveServer in the dropdown (as Dan did), if I do the following in App.razor, then it works.

<HeadOutlet @rendermode="InteractiveServer" />

and

<Routes @rendermode="InteractiveServer" />

This is not needed for dotnet 8.0, as it worked successfully without any changes to the App.Razor file.

There definitely seems to be an issue with the scaffolding if done the way Dan did it in his demo. Hopefully it will not be difficult to resolve.

@guardrex
Copy link
Contributor

guardrex commented Nov 14, 2024

I just hit this when walking the tutorial for 9.0 updates ...

https://learn.microsoft.com/en-us/aspnet/core/blazor/tutorials/movie-database-app/?view=aspnetcore-9.0

Image

Note @coderdnewbie that it isn't the "Even though this was selected as InteractiveServer in the dropdown" (Interactive render mode) setting that places the render mode on HeadOutlet/Routes. It's the Interactivity location setting. What you did by adding them manually made the interactivity location global instead of per page/component. The tutorial takes the per page/component approach because we have devs enable interactivity in the last article of the tutorial series for only the movies Index page.

I agree with you ... it's a regression of some sort. This behavior wasn't happening in 8.0.

@guardrex
Copy link
Contributor

guardrex commented Nov 14, 2024

@danroth27 ... UPDATE: I'm going with the 8.0 framework in the 9.0 content to workaround this for now. The change is ⚡LIVE⚡ now. Temporarily use 8.0 framework (dotnet/AspNetCore.Docs #34118). I have tracking in place to revert back to 9.0 when the problem is resolved in the framework.

I know from our earlier discussion on a separate doc task that you aren't favorable to that blaring red CAUTION note in articles 📣😬, but I really want devs to see the instruction on selecting the 8.0 framework. If they don't see it, they'll get rather upset when their app 💥, and it will probably result in doc issues. I'm just trying to head that off with the most noticeable notice that we have. If you want to remove or change the word "CAUTION," I can place HTML in the article for a red alert box. 👂

@coderdnewbie
Copy link
Author

coderdnewbie commented Nov 15, 2024

I definitely consider this a regression myself, as I have also found that if I try to upgrade from dotnet 8.0 to 9.0, the working solution from dotnet 8.0 fails in the same way, i.e. clicking the Create button causes the same failure in:

NavigationManager.NavigateTo("/movies");

@danroth27 can you try it out and verify with an existing dotnet 8.0 solution and try to upgrade to dotnet 9.0. The same thing happens as I described in my initial post when clicking the Create button.

Thanks.

@javiercn
Copy link
Member

javiercn commented Nov 15, 2024

This exception is thrown by the framework and handled by it. It's not a "new error" that's happening, it's simply that the debugger would not previously break on those exceptions and now it does.

If you hit continue or uncheck the "break on" checkbox, everything will continue working. (As in 8.0)

@guardrex
Copy link
Contributor

guardrex commented Nov 15, 2024

This results in a poor tutorial experience for 9.0. I'll need to tell devs to uncheck the break-on checkbox to avoid it constantly happening as they work through the tutorial.

I'll wait to hear a confirmation from @danroth27 that that's what he wants me to do.

BTW ... ❓... Why does the line throw at all? The navigation endpoint exists in the app.

@javiercn javiercn added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Nov 15, 2024
Copy link
Contributor

Hi @coderdnewbie. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@javiercn javiercn added Docs This issue tracks updating documentation and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Nov 15, 2024
@danroth27
Copy link
Member

@halter73 Where did you get in your investigations with the debugger team to prevent this exception from showing up?

@danroth27
Copy link
Member

This results in a poor tutorial experience for 9.0. I'll need to tell devs to uncheck the break-on checkbox to avoid it constantly happening as they work through the tutorial. I'll wait to hear a confirmation from @danroth27 that that's what he wants me to do.

@guardrex For now, I think we need to do this.

@coderdnewbie
Copy link
Author

I agree that this is a poor experience, but unchecking the break-on box worked for me, so will close this issue.

@danroth27 I still think this needs to have the same behavior as dotnet 8.0, so that the demo tutorials still work for others. Should we be using 'Global' rather than 'Per Page/Per Component' in the checkbox?

@guardrex
Copy link
Contributor

guardrex commented Nov 15, 2024

It will after the VS debugger is updated on a future release.

The written tutorial can't take that approach of going global because a latter step has the dev apply interactive SSR to a single component. It would be a large change to the tutorial series for a temporary gain. It's best to uncheck the box for now, and then I'll revert that guidance later when the next VS patch lands.

@guardrex
Copy link
Contributor

guardrex commented Nov 19, 2024

@danroth27 ... WRT ...

investigations with the debugger team to prevent this exception from showing up

Will the update land as a patch, or will the update be for .NET 10?

With this issue closed, I have nothing to track for reverting the tutorial content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components Docs This issue tracks updating documentation
Projects
None yet
Development

No branches or pull requests

4 participants