enkodellc / blazorboilerplate

Blazor Boilerplate / Starter Template with MudBlazor
MIT License
1.87k stars 372 forks source link

Should we convert to Server Side Blazor? #41

Closed enkodellc closed 4 years ago

enkodellc commented 5 years ago

Looking for opinions on switching Blazor Boilerplate to Server Side Blazor. I know it will be easier to debug and will be more stable. My end goal is still Client Side Blazor for my future deployments. So if you have an opinion please voice it in a comment. If we move to SSB it will happen with a 0.4.0 version.

JeroMiya commented 5 years ago

I'll be using Server-Side until Client Side is "officially released". I'd prefer the boilerplate project be server side at least initially. Supporting both would be ideal.

witoldlitwin commented 5 years ago

I agree that server-side conversion is a good idea. For now I plan to use SSB because of official MS support, stability and load speeds.

enkodellc commented 5 years ago

This looks like a great solution: https://github.com/Suchiman/BlazorDualMode it does both. @witoldlitwin / @JeroMiya / @msajidirfan anyone be willing to create a PR for this?

witoldlitwin commented 5 years ago

On it.

enkodellc commented 5 years ago

FYI @witoldlitwin , it looks like @NPadrutt tried and he had some issues with IS4. If you run into the same I suggest using the 0.2.3 release of BlazorBoilerplate. Though we have now sorted most of the IS4 issue. Hopefully it works for you without much hassle. I appreciate the work!

witoldlitwin commented 5 years ago

@enkodellc I added a PR, but the code in it is incomplete. I couldn't figure out how to solve a dependency injection issue with HttpClient. Take a look at the code, maybe you'll be able to fix it.

glazkovalex commented 5 years ago

Interested only the client side of blazor on WebAssembley. Server side (MVC) died about seven years ago and is of no interest. The server side of blazor is exclusively for legacy support.

valentasm1 commented 5 years ago

@glazkovalex Blazor server side is not near similar to MVC server side which you mention. With current stage of client side blazor it is only for internal usage. This article show how well server side is scalable.

@witoldlitwin is this maybe what you need?

// Server Side Blazor doesn't register HttpClient by default
            if (services.All(x => x.ServiceType != typeof(HttpClient)))
            {
                // Setup HttpClient for server side in a client side compatible fashion
                services.AddScoped<HttpClient>(s =>
                {
                    // Creating the URI helper needs to wait until the JS Runtime is initialized, so defer it.
                    var uriHelper = s.GetRequiredService<NavigationManager>();
                    return new HttpClient
                    {
                        BaseAddress = new Uri(uriHelper.BaseUri)
                    };
                });
            }
enkodellc commented 5 years ago

@glazkovalex thanks for the feedback. As of this moment it would be great to have a dual app that could be switched fairly easy until CSB / webassembly has debugging. That is the missing piece. If that is not possible I don't think I will convert the whole app to server side, Maybe a branch for SSB Blazorpoint for those who want to use it to test their Pages.

glazkovalex commented 5 years ago

Blazor server side is not near similar to MVC server side which you mention.

Blazor server side is similar to MVC in that its terrible disadvantage is that Blazor server side works in an archaic way on the server side, just like the long-dead MVC. Yes, the server side can be scaled to execute client logic, but why scale the server and waste traffic on unnecessary data exchange when client logic can be executed within hundreds and millions of client devices?!

The server side of blazor is exclusively for legacy support.

fudgeboy2000 commented 5 years ago

Client-side and server-side both have legitimate use cases. Being able to easily switch the project between the two models would be the killer feature for sure. I'd like to be using Blazor Boilerplate for projects right now, but client-side simply isn't a practical option for many reasons. Some of those may go away over the next 12 months (use of IE11, client-side not being officially supported yet, Ops lack of exposure to webassembly in general leading to skepticism), but some might not (scaleability on the server-side being an important aspect of locally hosted intranet webapps).

For now it's a great technology to sink R&D time into, and this project is a great resource in these early days, but lack of an option for the only officially supported distribution model is a big hurdle when doing enterprise development.

softwareguy74 commented 4 years ago

Both!

soomon commented 4 years ago

Blazor on the server side is nice and fast. I like that blazor offers both options. But in times of SPAs and tools like electron, I think the future is client side. Also, Microsoft will invest tons of time and money to achieve faster loading times, so in my view it is better to follow them and stick to the client side, although the loading times currently are quite long.

Also, I guess its less work to convert from Client to Server than the other way around, so that can always be done in a fork, if someone wants to.

MarkStega commented 4 years ago

I have a PR ready to go that implements switching between CSB/SSB by choosing the build configuration. I have one issue though and that is the flow through the authentication. I see in the account controller that a 200 status is being returned for the 'built in' users of user&admin, but they aren't ending up in a valid authenticated state. I use JWT authentication in my app with a custom authentication provider and really have no experience with an IS solution.

Is there anyone that could take this PR & understand how to fix the authentication?

[Edit] The PR is "2019-12-17 Dual mode supporting CSB & SSB #100"

enkodellc commented 4 years ago

Thanks @MarkStega, to anyone else willing to contribute help with debugging this issue. I created a branch for his PR "DualModeV2" which I merged his PR into.

VR-Architect commented 4 years ago

For me server-side development is by far the fastest to develop when the requirements are fluctuating. No need for API controllers, no need for Swagger, no need for Postman, no JWT token cut/paste, and faster debugging. In addition, if using EF Core and you change the database model in the database, just rerun the command to change the model/data classes.

HOWEVER, for enterprise applications the reality is that we really need both server-side(signal-R) and client-side(hosted on ASP.net) solutions. For many enterprises, mobile devices preference would be for disconnected local storage with syncing to the server. For desktops in the office, regular old web hosted is preferred. We will be creating a project that does both and leverages the shared DLL classes for page rendering and data models. Of the DAL and Identity areas would be different for each though.

Just my 2 cents.

MarkStega commented 4 years ago

The DualModeV2 branch is now complete (pending a merge of a PR) and allows the project to run as either CSB or SSB.

enkodellc commented 4 years ago

@MarkStega Thanks. I am checking the master PR's now and then will review your PR's for DualModeV2. I plan on getting to it by end of day.

enkodellc commented 4 years ago

Thanks to @MarkStega the branch "DualModeV2" is almost ready for release. If there is anyone in the list that has chimed in and wants to help by testing please fork that branch. Right now I see that the Forum is broken. I will be spending some time merging the latest changes from the master branch to it. Hoping to merge it into master in the next week, depending on any other bugs.

MarkStega commented 4 years ago

I just pushed a PR to the "DualModeV2" branch which has a repair to the SSB Forum functionality. As far as I know the branch now fully supports CSB & SSB.

enkodellc commented 4 years ago

Just merged @MarkStega 's PR Version 0.6.0 / Master Branch. We now have BlazorBoilerplate that can run both CSB and SSB. Please test it out and submit Issues / PR's. Happy Coding everyone!