Eilon / MauiHybridWebView

MIT License
216 stars 48 forks source link

Enhancement Request: Support for Desktop Refresh without 404 Errors #57

Open HelloooJoe opened 7 months ago

HelloooJoe commented 7 months ago

Description

When using the HybridWebView experiment in a .NET MAUI application on a desktop platform, refreshing the page leads to a 404 error. This issue affects the usability and the user experience, especially during development and testing phases.

Steps to Reproduce

  1. Run a .NET MAUI application that uses HybridWebView on a desktop platform.
  2. Navigate to any content within the HybridWebView that loads from a local or proxied resource.
  3. Refresh the page.
  4. The application shows a 404 error page instead of reloading the current content.

Expected Behavior

The application should reload the current page/content within the HybridWebView without any errors, preserving the user's state and context where applicable.

Actual Behavior

The application fails to find the requested page after a refresh and displays a 404 error, indicating that the resource cannot be found.

Possible Solutions or Suggestions

Question

Is handling refresh actions on the desktop within the scope of the HybridWebView control, or should it be managed at the application level? Any guidance on best practices or recommendations would be greatly appreciated.

Environment

Additional Context

Add any other context or screenshots about the enhancement request here.

image

MarkSky commented 2 months ago

I have the same error on Android Devices. MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:EZTestMauiApp"
             xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
             xmlns:ejl="clr-namespace:HybridWebView;assembly=HybridWebView"
             x:Class="EZTestMauiApp.MainPage"
             BackgroundColor="#ffffff">

    <ContentPage.Behaviors>
        <toolkit:StatusBarBehavior StatusBarColor="#000000" StatusBarStyle="Default" />
    </ContentPage.Behaviors>

    <RefreshView x:Name="refreshView" Command="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing}">
        <ejl:HybridWebView x:Name="hybridWebView" HybridAssetRoot="hybrid_root" RawMessageReceived="OnHybridWebViewRawMessageReceived" />
    </RefreshView>

</ContentPage>

MainPage.xaml.cs

public ICommand RefreshCommand { get; }
private bool isRefreshing;
public MainPage()
{
    InitializeComponent();
    RefreshCommand = new Command(ExecuteRefreshCommand);
    BindingContext = this;
}
private void ExecuteRefreshCommand()
{
    Debug.WriteLine("ExecuteRefreshCommand triggered");
    hybridWebView.Reload();
    Task.Delay(2000).ContinueWith(t =>
    {
        IsRefreshing = false;
        Console.WriteLine("After ExecuteRefreshCommand refreshView: " + refreshView.IsEnabled);
    });
}

There is 'Resource not found (404)' on the screen. Screenshot_1725615625

I use VueJS Framework to develop the UI, so it's a SPA web page. All the urls are virtual.