tryphotino / photino.Blazor

https://tryphotino.io
Apache License 2.0
332 stars 62 forks source link

Photino Blazor seemingly ignoring the file location given in app.Load method #62

Closed grofit closed 1 year ago

grofit commented 2 years ago

I am struggling to work out what the problem here is but due to a few factors I do not have my index page in wwwroot it is actually in wwwroot/_content/MyApp/index.html, this is mainly down to trying to get dependent dlls containing static content to output correctly as mentioned in #20, so the fix for that means my app now inputs into a folder within the wwwroot rather than in the root.

ANYWAY with that out of the way I have the following in my setup:

var rootIndexPage = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot\\_content\\MyApp\\index.html");
appLauncher.Load(rootIndexPage);

I can see in the loading logs its doing:

Photino.NET: "MyApp".Load(E:\Code\open-source\myapp\dist\wwwroot\_content\MyApp\index.html)
Photino.NET: "MyApp".Load(file:///E:/Code/open-source/myapp/dist/wwwroot/_content/MyApp/index.html)
Photino.NET: "MyApp".Load(http://0.0.0.0/)

So its finding the file correctly and if I browse to file:///E:/Code/open-source/myapp/dist/wwwroot/_content/MyApp/index.html in my browser the page is resolved but it blows us due to sandboxing on file:// etc.

The odd thing is if I drop an index.html into the wwwroot folder it uses that, so its like it ignores the provided path and just uses whatever index.html it can find in there, even if I give it a completely bogus url it says its loading it, but just loads the index.html that ive manually put in there.

So am I missing something here as I assumed the Load call was to tell it which page should be loaded, and in debug it works fine its just when I go to dotnet publish the app it seems to act differently, but I have no idea why.

This never used to be a problem as my stuff would output to wwwroot until I needed to depend on a nuget package which contained its own _content so the fix for that has led me to this position, but even so it still feels like the Load method is not doing what it says its doing.

gnalvesteffer commented 1 year ago

This is due to Photino.Blazor.PhotinoBlazorApp.Run() explicitly calling WindowManager.Navigate("/"); which ends up loading the index.html.

It would be nice if PhotinoBlazorApp.Run() optionally took in a path to an html file, which would also be useful for multi-window apps where different windows have different responsibilities and need to render something entirely different.

gnalvesteffer commented 1 year ago

I made a quick PR to address this: https://github.com/tryphotino/photino.Blazor/pull/87

MikeYeager commented 1 year ago

The fix to honor the Load() method has just been incorporated into https://github.com/tryphotino/photino.Blazor/pull/89