Asked by:
Web View issue ms-appdata vs ms-appx-web

Question
-
Hi,
In our UWP app there is a web view which loads a 3D model. The content of the web part includes a html, js, css and a file of type .iv3d. When I load that html like this ms-appdata:///local/models/index.htm from the LocalState folder it loads the model fine. But if I try to put that web code inside our project and call it like this ms-appx-web:///Screens/Test/index.htm it only loads the html file but not the 3D content. The html looks like below.
<script type="text/javascript" src="iv3d.js"></script> <link rel="stylesheet" type="text/css" href="ivstyles.css" /> </head> <body onload='view3d=iv.initViewer3d("tree.iv3d",0x777777,null,1.0);view3d.menuOpen=false;view3d.cfgSelZOffset=false;view3d.clrSelection[5]=false?0.5:1;' >
Any idea why it doesn't work in the second way?
Also if it is not going to work, I think what I'll have to do is copy those files to the LocalState folder at the start and access it from there. Can you please direct me how I can copy some files inside my UWP project to the LocalState folder.
Thank you.
Madhu
All replies
-
Hi,
I'm sorry to say that I can't reproduce the unexpected behavior you said about the 3D model. I created an HTML file using the code you are given, but I can't see anything in browser or in WebView control in UWP apps. So I can't tell what causes the issue. But I'll answer the second question.
>>Can you please direct me how I can copy some files inside my UWP project to the LocalState folder.First you could access the installation folder using Windows.ApplicationModel.Package.Current.InstalledLocation. Then you could use StorageFile.CopyAsync Method to copy the file.
Here is the code sample that I get a file from the Assets of the installation folder and copy it to the models folder in the local folder.//get file from installation folder string CountriesFile = @"Assets\london.png"; StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation; StorageFile file = await InstallationFolder.GetFileAsync(CountriesFile); //copy file to local folder StorageFolder localFolder = ApplicationData.Current.LocalFolder; StorageFolder modelfolder= await localFolder.GetFolderAsync("models"); Debug.WriteLine(modelfolder.Path); StorageFile copiedFile = await file.CopyAsync(modelfolder, file.Name, NameCollisionOption.ReplaceExisting);
Besides, we invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!
Best regards,
Roy
"Developing Universal Windows apps" forum will be migrating to a new home on Microsoft Q&A (Preview)!
We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!
For more information, please refer to the sticky post.
- Edited by Roy LiMicrosoft contingent staff, Moderator Friday, November 8, 2019 2:58 AM
-
Thank you very much Roy.
When you get a chance please check whether this web page works for you.
https://drive.google.com/file/d/1pj-SazaHFOsWCikIzAd0EfKQ4EV8wApN/view?usp=sharing
Model will open for this (it will take couple of minutes to load)
ms-appdata:///local/models/1/index.htm
But for this only the html loads
ms-appx-web:///Screens/Test/1/index.htm
Thanks,
Madhu
-
Hi,
I'm here to update my test result. I tried the html, the html shows 100% in its page. But no more things. I tried to open the html in the browser, after the process ring became 100%, it shows there is a 404 error in iv3d.js.
I suspect when using ms-appx-web to open the htm, it is opened as a file not a website. So that it just shows a static page. Currently you could try to copy it to the local file and access it using ms-appdata:
By the way, We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!
Best regards,
Roy
"Developing Universal Windows apps" forum will be migrating to a new home on Microsoft Q&A (Preview)!
We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!
For more information, please refer to the sticky post.- Edited by Roy LiMicrosoft contingent staff, Moderator Tuesday, November 26, 2019 2:07 AM edit