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

Update Blazor (ASP.NET Core Hosted) project template so that it is easy to toggle between client-side and server-side Blazor #6882

Closed
danroth27 opened this issue Jan 20, 2019 · 2 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one Needs: Design This issue requires design work before implementating. Needs: Spec Indicates that a spec defining user experience is required

Comments

@danroth27
Copy link
Member

danroth27 commented Jan 20, 2019

The work that remains here is to break up UseBlazor into more parts so that it looks similar to the patterns for server-side.

@danroth27 danroth27 added this to To do in Blazor via automation Jan 20, 2019
@danroth27 danroth27 added this to the 3.0.0-preview3 milestone Jan 20, 2019
@danroth27 danroth27 added 1 - Ready enhancement This issue represents an ask for new feature or an enhancement to an existing one area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Jan 20, 2019
@SteveSandersonMS SteveSandersonMS added the area-blazor Includes: Blazor, Razor Components label Feb 6, 2019
@danroth27 danroth27 added the Needs: Design This issue requires design work before implementating. label Feb 25, 2019
@danroth27 danroth27 moved this from To do to Design in Blazor Feb 25, 2019
@mkArtakMSFT mkArtakMSFT added Needs: Spec Indicates that a spec defining user experience is required PRI: 1 - Required labels Mar 9, 2019
@mkArtakMSFT mkArtakMSFT added this to To do in Blazor Apr 15, 2019
rynowak pushed a commit that referenced this issue Apr 17, 2019
This design concept splits up UseBlazor into a usage of static files and
a usage of MapFallback.

---

I ignored auto-rebuild support because it's currently dead code until we
have that in VS. If we add auto-rebuild to ASP.NET Core - we'd probably want
to make that a separate gesture inside `IsDevelopement()` like other
dev-time features anyway.

---

The static-files wireup is pretty thick, and comes with some caveats.
This requires you to use the StaticFiles middleware without passing in
an explicit options instance. This gives us parity with what we're doing
for server-side, but it still gives me a bit of pause. Note that this
supports multiple calls to include multiple projects.

Another approach would be to make a separate `UseClientAppFiles()`
middleware. This wouldn't be quite so fragile.

Basically the approach in the PR optimizes the Startup code being
simpler but requiring a little more explanation. We could optimize the
other way by making an explicit middleware.

---

I feel pretty good about the wireup with routing to use the
`index.html` from the client app. I think it's pretty to-the-point.
@mkArtakMSFT mkArtakMSFT moved this from To do to In progress in Blazor Apr 17, 2019
rynowak pushed a commit that referenced this issue Apr 18, 2019
This changes the recipe for client-side blazor to use similar primitives
to server side applications.

---

I ignored auto-rebuild support because it's currently dead code until we
have that in VS. If we add auto-rebuild to ASP.NET Core - we'd probably want
to make that a separate gesture inside `IsDevelopement()` like other
dev-time features anyway.

---

The static files hookup is a special thing because creating the file
server for a client-side Blazor app involves some non-trivial work. We
plan to make this better in the future.

What's nice about this pattern is that the implementation is pretty
simple and literal, and it scales fine if you have multiple Blazor
client-side apps.

I didn't provide a lot of options here, it's pretty much the same as
UseBlazor.

---

I feel pretty good about the wireup with routing to use the
`index.html` from the client app. I think it's pretty to-the-point.
@mkArtakMSFT mkArtakMSFT removed this from In progress in Blazor Apr 19, 2019
@StevenTCramer
Copy link
Contributor

@rynowak looks like you are going this direction. (One configuration for both client and sever side)

https://github.com/TimeWarpEngineering/blazor-state/blob/master/test/TestApp/TestApp.Client/wwwroot/BlazorDualMode.js

Gives the ability to select client-side or server-side Blazor at run-time without recompiling.

https://github.com/TimeWarpEngineering/blazor-state/blob/master/test/TestApp/TestApp.Server/Startup.cs

This allows the same server to handle either type of client. The default usage is first visit the client operates server-side second-visit when all is cached it switches to client side. But all kinds of logic could be put in this to determine dynamically where is the best user experience.

https://thefreezeteam.com/razor-components-dynamic-dual-mode/

This is a very nice use case that I just hope we can maintain :)

@mkArtakMSFT mkArtakMSFT added this to In progress in Blazor May 1, 2019
rynowak pushed a commit that referenced this issue May 3, 2019
This changes the recipe for client-side blazor to use similar primitives
to server side applications.

---

I ignored auto-rebuild support because it's currently dead code until we
have that in VS. If we add auto-rebuild to ASP.NET Core - we'd probably want
to make that a separate gesture inside `IsDevelopement()` like other
dev-time features anyway.

---

The static files hookup is a special thing because creating the file
server for a client-side Blazor app involves some non-trivial work. We
plan to make this better in the future.

What's nice about this pattern is that the implementation is pretty
simple and literal, and it scales fine if you have multiple Blazor
client-side apps.

I didn't provide a lot of options here, it's pretty much the same as
UseBlazor.

---

I feel pretty good about the wireup with routing to use the
`index.html` from the client app. I think it's pretty to-the-point.
rynowak pushed a commit that referenced this issue May 6, 2019
This changes the recipe for client-side blazor to use similar primitives
to server side applications.

---

I ignored auto-rebuild support because it's currently dead code until we
have that in VS. If we add auto-rebuild to ASP.NET Core - we'd probably want
to make that a separate gesture inside `IsDevelopement()` like other
dev-time features anyway.

---

The static files hookup is a special thing because creating the file
server for a client-side Blazor app involves some non-trivial work. We
plan to make this better in the future.

What's nice about this pattern is that the implementation is pretty
simple and literal, and it scales fine if you have multiple Blazor
client-side apps.

I didn't provide a lot of options here, it's pretty much the same as
UseBlazor.

---

I feel pretty good about the wireup with routing to use the
`index.html` from the client app. I think it's pretty to-the-point.
@rynowak rynowak closed this as completed in d3400f7 May 7, 2019
Blazor automation moved this from In progress to Done May 7, 2019
@Andrzej-W
Copy link

Will this enable server side prerendering for Blazor Client Side app?

@mkArtakMSFT mkArtakMSFT added Done This issue has been fixed and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates 2 - Working labels May 9, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
@jaredpar jaredpar removed this from Done in Blazor Jan 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one Needs: Design This issue requires design work before implementating. Needs: Spec Indicates that a spec defining user experience is required
Projects
None yet
Development

No branches or pull requests

8 participants
@StevenTCramer @SteveSandersonMS @rynowak @danroth27 @ryanbrandenburg @Andrzej-W @mkArtakMSFT and others