-
Notifications
You must be signed in to change notification settings - Fork 62
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
How to set up Photino for .NET 8 Blazor Web App? #108
Comments
Thank you for reporting this. I have added this to our backlog of issue to investigate. |
@SommerEngineering We noticed that your sample doesn't have an index.html page in wwwroot. You'll notice that all of our samples (located in the Photino.Blazor project) have one that helps bootstrap Blazor. The most basic version of that file is this:
That will take care of the immediate issue. Beyond that, there is still a problem with these lines:
I'm not a Blazor guru by any stretch, but I can't see why you'd want to run Blazor in server mode inside of Photino. By default, the builder sets up for desktop mode. I tried a few things to add server support as well, just for fun, but I wasn't able to get it working. Here is what the default builder does:
and the default Build():
|
Thanks for the response, @MikeYeager and @ottodobretsberger.
That's right: I strictly followed the new template from Microsoft for .NET 8. The new Blazor web app template from Microsoft does not use
I don't know, either. As I said, I have only tried to get the Microsoft template for .NET 8 to run with Photino. The desktop mode will then probably fit 👍 .
Thanks for trying it out. Having the standard .NET 8 template for "Web Apps" work with Photino would certainly lower the barrier to entry for many potential users. As you may have seen, I have now got the .NET 8 web app running with Photino.NET. For this purpose, I added another project to the solution. This worked wonderfully by running the web server asynchronously. With a using System.Drawing;
using PhotinoNET;
using PhotinoNetApp.Components;
//
// Standard .NET 8 template for web apps:
//
var builder = WebApplication.CreateBuilder();
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.WebHost.UseWebRoot("wwwroot");
builder.WebHost.UseStaticWebAssets();
// I specified the URL with a port:
builder.WebHost.UseUrls("http://localhost:5000");
var app = builder.Build();
app.UseStaticFiles();
app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
//
// End of standard template
//
// Using a cancellation token source, so we can exit the web server later:
using var webServerCancellation = new CancellationTokenSource();
// Run the webserver async in the background (no await used here):
var webServerTask = app.RunAsync(webServerCancellation.Token);
// Create the Photino window:
var window = new PhotinoWindow()
.SetTitle("Test App")
.SetUseOsDefaultSize(false)
.SetSize(new Size(1024, 900))
.Center()
.SetResizable(true)
// ... and load the web content at the URL / port:
.Load("http://localhost:5000");
// Wait until the Photino window was closed:
window.WaitForClose();
// Cancel the webserver using the token:
webServerCancellation.Cancel();
// Wait for the server to stop:
await webServerTask; |
I'm also really looking forward to a solution to this problem. |
I know that this doesn't solve your problem, but my Photino Blazor app runs with .NET 8 |
I have tried to run a .NET 8 Blazor Web App (the new templates added with the .NET 8 release) with
Photino.Blazor
. Unfortunately, without success so far. Therefore, I have built a minimal working example (MWE): https://devops.tsommer.org/mwe/issues/net8blazorI have two projects:
PhotinoApp
andWebApp
. TheWebApp
project is the official .NET 8 template for web apps with minimal changes (simplifications for the MWE). This works perfectly in the local browser.The
PhotinoApp
project is also the same template, but with the necessaryPhotino.Blazor
adaptations. Here is, what I have done:PhotinoApp.csproj
:<OutputType>WinExe</OutputType>
Photino.Blazor
package (v2.7.0)Finally, I changed the
Program.cs
from this ...... to this ...
The result looks like this:
The logging shows this:
Can anyone help me with this 😀 ? Has anyone gotten the new .NET 8 Web App template to work with Photino?
Should we solve the issue, we could directly add a new example project to the
Photino.Blazor
repo so that other users can find the solution more easily and quickly.The text was updated successfully, but these errors were encountered: