MicrosoftEdge/WebView2Feedback

Long File Paths result in Broken Content when using SetVirtualHostNameToFolderMapping

cmiles opened this issue · 4 comments

When using SetVirtualHostNameToFolderMapping long file paths result in broken content.

Version
SDK: 6.0.100-preview.6.21355.2
Runtime: 92.0.902.55
Framework: WPF
OS: Windows 10 Pro 21H1
Package: 1.0.955-prerelease

Repro Steps
Call CoreWebView2.SetVirtualHostNameToFolderMapping and set a Source that results in the WebView2 trying to load a file with a path longer than Windows MAX_PATH.

I setup a small repo - cmiles/WebView2VirtualHostNamePathLengthProblem - to experiment with the issue. This repo contains example code and information.

I'm not sure that any of this should have an impact of WebView2 loading long file path content but I did try: setting Win10 group policy to remove MAX_PATH limitations, including an app.manifest with longPathAware set to true and calling CoreWebView2.SetVirtualHostNameToFolderMapping with the \\?\ syntax - none of those seemed to have any impact.

ScreenSnipShowingBrokenImage

The screen shot above is from the sample repo and shows:

  • In the top panel the source is set to an html file that is below MAX_PATH value and loads, but the top image is a link to a file beyond the MAX_PATH - the error is: Failed to load resource: net::ERR_ACCESS_DENIED
  • In the bottom panel the source is set to a file with a long enough name to be over the MAX_PATH and it fails to load

AB#34878592

Thanks @cmiles for the bug report and the repro app! This is a known limitation currently of file loading, and I believe it also affects Microsoft Edge and Chromium. I'll open this bug on our backlog, but in full transparency it's likely to be lower priority for us. Thanks!

@champnic Thanks for the quick reply and information - glad this will stay open even if the chances are slim it gets fixed... Not sure if this is the right place to mention this but for me CoreWebView2.SetVirtualHostNameToFolderMapping(String, String, CoreWebView2HostResourceAccessKind) Method (Microsoft.Web.WebView2.Core) | Microsoft Docs would have been a great spot to find information on that limitation.

Better knowing the problem/limitation now I might be able to find out via search but If anyone is aware of a well known/common work around (other than to just not end up in this situation!!) I would appreciate a quick note or link.

I've opened a bug to improve our docs and include that info :)