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

Webview2 not able to upload stream more than 65MB stream in "CoreWebView2.Environment.CreateWebResourceResponse(stream, 200, "OK", string.Empty);" #4816

Open
mdCllang opened this issue Sep 17, 2024 Discussed in #4525 · 0 comments

Comments

@mdCllang
Copy link

Discussed in #4525

Originally posted by SajidMemon44 May 3, 2024
Hi,

I am using webview2 , i want to send file using "CoreWebView2.Environment.CreateWebResourceResponse(stream, 200, "OK", string.Empty);" file size is more than 70MB it was cause error

at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at WinProjectE.App.Main()

System.Runtime.InteropServices.SEHException
HResult=0x80004005
Message=External component has thrown an exception.
Source=
StackTrace:

Method used :

private void CoreWebView2_WebResourceRequested(object sender, CoreWebView2WebResourceRequestedEventArgs e)
{
if (e.Request.Uri.Contains("/XXX/XXX/XXX/XXX/", StringComparison.OrdinalIgnoreCase))
{
string filename = Path.GetFileName(e.Request.Uri);
string filePath = Path.Combine(App.oGlobalInput.TempDirectory, filename);

                if (File.Exists(filePath))
                 {
                            FileStream stream = File.OpenRead(filePath);
                            e.Response = parent.webView.CoreWebView2.Environment.CreateWebResourceResponse(stream, 200, "OK", 
                               string.Empty);
               }
                else
                {
                            e.Response =
                               parent.webView.CoreWebView2.Environment.CreateWebResourceResponse(null, 404, "File not found", string.Empty);
                }
      }

}

We try this approach as well but still same error : https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/working-with-local-content?tabs=dotnetcsharp

Webview2Error

Some additional Infos:
We use WPF, NetFramework 4.8,
Nuget: Microsoft.Web.WebView2: Versions tested: 1.0.1823.32 and 1.0.2151.40 (latest at moment of posting)

TestPC runs on Windows 11:
WebView2 Runtime: 128.0.2739.79 (latest at moment of posting)

Any suggestions or ideas how to fix it would be nice.

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

1 participant