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

We need a Blazor WebAssembly new-project template with ASP.NET hosting that allows new adopters to actually be able to adopt Blazor WebAssembly (sic) - like we used to have before .NET 8 #59887

Closed
1 task done
Bellarmine-Head opened this issue Jan 15, 2025 · 4 comments
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@Bellarmine-Head
Copy link

Bellarmine-Head commented Jan 15, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

It's very difficult for new adopters to get a classic Client, Server, Shared, ASP.NET-hosted Blazor WebAssembly (BWA) solution because the current new-project template won't generate one. It doesn't clearly identify the Server project, it omits a Shared project, and it doesn't show how the Client project would get data from the Server (it fakes it!). It also asks questions of a new user that they couldn't possibly answer ("Interactivity Location").

Beginners aren't even going to know that a Shared project (class library) is common and natural, nor that shared data model classes are a thing.

This not only harms new adoption rates, it also makes it harder for seasoned pros who started before November 2023 to stand up a new BWA website without a lot of referring back to previous solutions, and a lot of manual editing.

If I was looking at Blazor WebAssembly as something I might adopt right now, in January 2025, the fact that the Client project fakes the loading of the data from the server - giving me no idea of how to do it for real - would mean a hard pass. Back to Angular or React or whatever. What an EPIC FAIL.

For further confirmation of how bad this is see here:-

Quote from the last link above: "The new templates are horrible for beginners."

The huge, current worry is that the closest outstanding issue that touches on this - started by @SteveSandersonMS himself - is backlogged!

Without this being done soon, and certainly by the .NET 10 milestone, I fear for the future of Blazor WebAssembly as something thriving and growing and living. As things currently stand, Blazor is a "closed club" - understandable and navigable only by those of us who achieved escape velocity because we were lucky enough to adopt before November 2023.

Describe the solution you'd like

There should be a new-project template that:-

  • has the classic Client, Server and Shared projects, like we had before .NET 8
  • the Server project needs to be named as such, as before
  • shows in the Client project how to get data from a controller action in the Server project via a shared data model class in the Shared project
  • doesn't fake anything
  • does a much better job than the current template of explaining user choices like "Interactive Render Mode" and "Interactivity Location"
  • emphasizes classic Blazor WebAssembly, but without necessarily closing the door on later adoption of server-side pre-rendering and such
  • generally addresses all the points made here - a new user shouldn't have to do all that stuff! Indeed, how could they?

More generally: stop making Blazor the "closed club" that it currently is.

Additional context

No response

@ReinoutWW
Copy link

ReinoutWW commented Jan 17, 2025

I'm interested in this as well! As a beginner in Blazor WebAssembly it is a challenge to understand this flow (Still till today).

Additionally, I also pick up signals that developers around me seem to think that they can create a WebAssembly project + Class library, which calls the database and be done. But it isn't so simple in SPA's, is it? How about securing data? (Same for moving from Blazor Server to WebAssembly). That, including what is said above would be a great template.

For security, this source pointed me in the right direction and to understand that it isn't so simple:
Image
Src: https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/?view=aspnetcore-9.0

@Bellarmine-Head
Copy link
Author

Bellarmine-Head commented Jan 18, 2025

"Have the client-side Blazor WebAssembly app call the server-side...."

How?

The new-project template shows no examples of the client-side BWA app calling anything.

Instead you get this:-

// Simulate asynchronous loading to demonstrate a loading indicator
await Task.Delay(500);

var startDate = DateOnly.FromDateTime(DateTime.Now);
var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" };
forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
    Date = startDate.AddDays(index),
    TemperatureC = Random.Shared.Next(-20, 55),
    Summary = summaries[Random.Shared.Next(summaries.Length)]
}).ToArray();

which is totally useless.

FWIW, my client-side BWA apps always call controller actions in the Server projects, which in turn call APIs. No secrets are exposed in the client, and there are no CORS issues.

@sakib1361
Copy link

This is very much needed. In the current template model, it is totally ignored that there is a good side thing on blazor which is its blazor webview. Previously I could just extend the default template and use blazor on wasm(PWA), server (API) and devices(BlazorWebview). Current templates totally ignore this beautiful combination where u can develop wasm and server separately without thinking of how and where it is rendering and if data is getting fetched twice.

Really not sure what happened to the web api with wasm and server. Think template developers didn't understand it too and put random data in WeatherForecast within WASM and didn't know how to get this from server altogether.

Out of all the template, there is no way to send a user event on wasm and do some db work and return the response. So not sure how to work with a form submission now with current so called "INTERACTIVITY". Interactivity is nice to have for professional developer but under no circumstances, it should be a priority over a necessity like simple web api calls.

@javiercn javiercn added this to the .NET 10 Planning milestone Jan 21, 2025
@javiercn javiercn marked this as a duplicate of #57008 Jan 21, 2025
@javiercn
Copy link
Member

We've brought back #55307 from the backlog and we plan to use that for tracking purposes.

We won't be resurrecting the old hosted webassembly template as it was, but we want to find a way to bring back the sample HttpClient call in a way that makes sense.

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
Projects
None yet
Development

No branches or pull requests

4 participants