SteveSandersonMS / WebWindow

.NET Core library to open native OS windows containing web UI on Windows, Mac, and Linux. Experimental.
Apache License 2.0
1.99k stars 214 forks source link

Blazor Sample page reload (F5) fails. #95

Open Apollo3zehn opened 4 years ago

Apollo3zehn commented 4 years ago

When I hit F5 in the browser, Blazor is not restarting properly. My use case is the following:

I try to run the app via ComponentsDesktop.Run<Startup>("My Blazor App", "wwwroot/index.html");. After the application has started the user is able to authenticate using MSAL with a call to

var webViewOptions = new SystemWebViewOptions()
{
    BrowserRedirectSuccess = new Uri("http://app/"),
    OpenBrowserAsync = uri => this.NavigateToAsync(uri)
};

await _app.AcquireTokenInteractive(_scopes)
        .WithSystemWebViewOptions(webViewOptions)
        .ExecuteAsync();

Without any options this would open the system`s browser, let the user sign in to the Microsoft account and then the window stays open to be closed manually.

However, I would prefer to use WebWindow to handle the login process. With the SystemWebViewOptions instance I am able to navigate to the login page. So that part works.

Now I set the property BrowserRedirectSuccess to new Uri("http://app/") to automatically navigate back on successful authentication but unfortunately that just displays the index.html file without fully starting Blazor. Maybe the javascript file is not loaded properly?