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

Directly render Blazor component on PHP page (ASP.NET Core 8) #1124

Open
marinasundstrom opened this issue Oct 4, 2023 · 3 comments
Open

Comments

@marinasundstrom
Copy link

marinasundstrom commented Oct 4, 2023

I want to embed a Razor component in a PHP page.

I would like to render a Razor component in any render mode directly on a PHP page - which should be possible with ASP.NET Core 8.

I have experience from rendering CSHTML partials in previous projects - for the Peachpie-based Wordpress specifically, but I want to do it the new way as of .NET 8.

@marinasundstrom
Copy link
Author

marinasundstrom commented Oct 4, 2023

Basing this on the existing methods in Peachpie:

public static class HttpContextExtension

Perhaps this will be of use when rendering: https://github.com/dotnet/aspnetcore/blob/426ed0fe108dec7cdb713815780d446d163a764c/src/Components/Endpoints/src/Results/RazorComponentResultExecutor.cs

Here is the more user-friendly API:
https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-components-outside-of-aspnetcore?view=aspnetcore-8.0

Then there is the issue with allowing interactivity by serving the necessary script, which I have solved:
https://github.com/marinasundstrom/BlazorMinimalApiTest

Hopefully, they will open this up, and support this.
The issue is: dotnet/aspnetcore#50762

@marinasundstrom
Copy link
Author

Here's an incomplete POC: https://github.com/marinasundstrom/BlazorPhp

It can only render components as static HTML. The renderer doesn't support the other render modes.

I wanted to use the EndpointHtmlRenderer but unfortunately, it is internal.

@jakubmisek
Copy link
Member

Hello @marinasundstrom , is there anything we can improve/implement in our API?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants