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

Could this be made to work with BlazorWebView - in Hybrid Wpf App #9

Open
mediabuff opened this issue Apr 8, 2023 · 7 comments
Open

Comments

@mediabuff
Copy link

mediabuff commented Apr 8, 2023

In MainWindow.xaml, I replace the webview control and took necessary steps in wiring the resource handlers. I get 'System.UriFormatException' when the view gets rendered.

New
<blazor:BlazorWebView x:Name="webView" HostPage="wwwroot\index.html" Services="{StaticResource services}"> <blazor:BlazorWebView.RootComponents> <blazor:RootComponent Selector="#app" ComponentType="{x:Type local:Main}" /> </blazor:BlazorWebView.RootComponents> </blazor:BlazorWebView>

Old
<wv2:WebView2 Grid.Row="0" x:Name="Browser" Source="https://cefsharp.test/" />

my Index.cshtml

`

<title>BlazorApp2Demo</title> @(await Html.RenderComponentAsync(RenderMode.Static, new { SectionName = "HeadCss" }))
Loading...
<div id="blazor-error-ui">
    An unhandled error has occurred.
    <a href="" class="reload">Reload</a>
    <a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.webview.js"></script>
@(await Html.RenderComponentAsync<SectionComponent>(RenderMode.Static, new { SectionName = "BodyScripts" }))
`
@mediabuff mediabuff changed the title Could this be make to work with BlazorWebView Could this be made to work with BlazorWebView - in Hybrid Wpf App Apr 8, 2023
@amaitland
Copy link
Collaborator

Could this be made to work with BlazorWebView

Interesting idea. Not something I've tired, so it's unclear if it's possible.

'System.UriFormatException' when the view gets rendered.

What is the stack trace for the exception?

If you can, create a new example project then create a PR, even if it's not working I'll be able to see exactly what you've done. As it is now you've only provided code fragments, not enough for me to know what's going on.

@mediabuff
Copy link
Author

Ok, I will try to recreate this in a smaller, boilder plate WPF hybrid blazor app. Please give me couple of days.

@mediabuff
Copy link
Author

Hi, please see attached Blazor.AspNetCore.Bridge.zip

Normall, Blazor server apps start with "_host.cshtml", a razor view that can dynamically configure the SPA page.
Microsoft has not done the same for Blazor Hyrbid Wpf App. The start up here is "index.html". Essentially, to start with I will be nice have "index.cshtml"
Now, this can be broadly expanded to include any Razor view in Blazor Hybrid. Today they only support Blazor(Razor Components - aka - *.razor files.

Micrsoft seems to go in the direction of supporting Client Side Rendering tech on the Server.

Server-side rendering with Blazor components
https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-8-preview-3/
See https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-8-preview-2/
https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-8-preview-1/

What they may not support is Client-side rendering of Server razor views.
Blazor.AspNetCore.Bridge.zip

I had raised this with MS
dotnet/aspnetcore#47613

@mediabuff
Copy link
Author

You may use the following libray to add some components to "index.cshtml" for testing purposes
https://github.com/inspgadget/BlazorSections

@amaitland
Copy link
Collaborator

please see attached Blazor.AspNetCore.Bridge.zip

I don't review zip files. Needs to be a PR against this repo that adds a blazor example that reproduces the exception you've reported above.

@mediabuff
Copy link
Author

oh, well. I am not familiar with how to do that as this is not simple few lines of bug. This is an architectural enhancement - that is the reason I gave you the source for the full project.

I thought I could peek your interest. Sorry! I will seek another route.

@amaitland
Copy link
Collaborator

I replace the webview control and took necessary steps in wiring the resource handlers. I get 'System.UriFormatException' when the view gets rendered.

  • Fork the project
  • Commit your changes
  • Push them to github for review.
  • Post a link here to your fork

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