dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.46k stars 10.03k forks source link

Change request: Default Render mode #57396

Open Trubador opened 2 months ago

Trubador commented 2 months ago

I would appreciate if <Routes @rendermode="InteractiveServer" /> is set by default in the App.razor file for Dotnet 8+ projects as I have experienced multiple times wasting time trying to figure out why some interactive element in my Blazor web app did not work, while other elements did work and I think it makes sense to enable this by default to not cause issues when in the development phase and then urge developers to change the setting after reading the documentation on the per page/component or global render modes. It would have saved me a lot of hours troubleshooting why the site did not render correctly and I would prefer having a project where it functions out of the box as a server side project rather than optimizing it for static site generation or web assembly, which introduce additional rendering complexity.

The App.Razor file' section should look the following:

App.razor

<body>
    <Routes @rendermode="InteractiveServer" />
    <script src="_framework/blazor.web.js"></script>
</body>
javiercn commented 2 months ago

@Trubador thanks for contacting us.

It's not clear what you are asking for. Are you suggesting eliminating the interactivity "none" option?

The template already has sticky options, so if you check server, the next time server will be preselected.

Trubador commented 2 months ago

Hi @javiercn

No I am not suggesting to remove the "none" option. I would just prefer if the template by default, if given no interactivity options either in dotnet new blazor command or in the Visual Studio project template, would set interactive render mode = "Server" and especially interactivity location = "Global" as this was usually my problem at least.

The problem has mainly come up when using templates from other people such as with the Dotnet Aspire template and Mudblazor templates as those were not setup by default to have this interactivity such that they would work correctly out of the box when adding new razor components. Thus to prevent such confusion in future templates I think it would be nice to set this default at the root domain of the issue in a manner as the attached image: image

What is your opinion on this?