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.43k stars 10.01k forks source link

First class component support for Multi Page Applications #38112

Closed javiercn closed 10 months ago

javiercn commented 2 years ago

Components play a prevalent role in modern web applications. They offer the widest reach when it comes to targeting multiple platforms with a single abstraction. However, the experience from multiple page apps (MVC/Razor pages) is "subpar". The only way to render a component is via an HtmlHelper or a TagHelper, both of which negate most of the benefits components offer compared to HtmlHelpers and TagHelpers.

Having the same level of support for components in Multiple Page Apps will empower developers and library authors to leverage primitive as the universal building block for web UIs across all platforms (WebView, SPA, MPA).

It will enable our existing MPA customers to leverage our current investments in Components to make progressive enhancement scenarios easier to implement and enhance their apps.

In addition to this, components offer a much better composition model than Tag Helpers and Html Helpers for a few reasons:

It offers more natural integration points between MPAs and Blazor by reducing the friction of adding Blazor Server and WebAssembly components to your app. Rendering a Blazor Server or WebAssembly component can be reduced to adding a special attribute directive to the tag, like @server or @wasm. Prerendering can be handled in a similar fashion like @prerender or via some other similar mechanism.

Supporting render fragments can be a challenge, however it is doable with a clear set of rules on what is allowed and what is not, that are reasonably easy to explain.

danroth27 commented 1 year ago

@javiercn Does this issue effectively cover https://github.com/dotnet/aspnetcore/issues/7528?

javiercn commented 1 year ago

@danroth27 no, this is more about being able to render components as tags inside MVC/Razor pages naturally and do things like render server/wasm components in that way too.

javiercn commented 1 year ago

@danroth27 this is largely a compiler ask, provided we figure out the runtime apis and the generated code (that bit is on us).

domagojmedo commented 1 year ago

Being able to just drop in wasm component in MVC/Razor page would 🔥 I know it's possible right now, but it would be great if it would be much simpler

stap123 commented 1 year ago

This would be great, we would love to be able to use Blazor inside our current MVC views in the same way we can JS now. The main attraction (apart from no JS ;) ) I think is that we would be able to use a component library with all of it's benefits across all app types.

savionlee commented 1 year ago

This would be helpful with our in house MVC migration because I could leap to elements that would be better as blazor components with its own logic.

sgf commented 1 year ago

Multi Page App is a very important part of the Web. If Blazor supports building it, Blazor will become a real web development framework.We will can be use it do more.

westonwalker commented 1 year ago

The idea of building server-rendered apps like we do today with MVC or Razor pages but being able to use blazer components to break up the views sounds amazing.

dlandi commented 1 year ago

Are we there yet? Status? Thanks!

SteveSandersonMS commented 1 year ago

Thanks for all the positive remarks here. We are doing a few investigations to explore the options and will come up with design proposals when we can.

mvacha commented 1 year ago

Thanks for all the positive remarks here. We are doing a few investigations to explore the options and will come up with design proposals when we can.

That's uplifting to hear, I have to say that the whole Asp.net Core team has done a great job with Blazor. It is currently the most efficient way to create Single-Page Applications. However, when it comes to working with Razor Pages, the experience feels quite outdated and even frustrating in comparison to not only the JavaScript world but also Blazor. "Components" via partial templates and the unreliable hot reload feature are examples of this.

It is encouraging to learn that Multi-Page Applications are now receiving more attention. Many teams are recognizing the added complexity of SPAs and rediscovering the benefits of MPAs, as seen with projects such as Astro and Htmx.

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

KennethHoff commented 11 months ago

Is this not completed now in AspNetCore 8 with Blazor SSR?

SteveSandersonMS commented 11 months ago

Yes, I think that's correct. Thanks for the reminder!

@mkArtakMSFT @javiercn Perhaps the only part of the description that isn't complete is support for passing RenderFragment across mode boundaries. We do have a more specific issue covering that: https://github.com/dotnet/aspnetcore/issues/46991. So if you agree, we can close this. If there are any other bits of incomplete work perhaps separate issues could be created for those, since the broad goals of this issue are now achieved.