Answered by:
WebView displayes "Navigation to the webpage canceled", while navigating from one XHTML page to another XHTML page.

Question
-
Hi, I found a question on stack overflow, that says he can't navigate from one XHTML to another XHTML. The first XHTML document contains anchor URL of 2nd XHTML document. If I include those XHTML docs in project & then run, I am getting effective output, but if XHTML docs are in local folder the webview displayes "Navigation to the webpage canceled" in release mode. In debug mode just-in-timer debugger gets launched.
XHTML docs within project, it loads and navigates successfully.
private void Load_Click(object sender, RoutedEventArgs e) { BlankWebView.Source = new Uri("ms-appx-web:///Assets/nav.xhtml"); }
XHTML docs in local folder, it loads but while navigating it says "Navigation to the webpage canceled" in release mode. In debug mode just-in-time debugger displays.
private async void Load_Click(object sender, RoutedEventArgs e) { var XHTML = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("nav.xhtml"); BlankWebView.NavigateToString(await Windows.Storage.FileIO.ReadTextAsync(XHTML)); }
How can I solve this issues ? If you want XHTML files, you can get from here
Thursday, May 9, 2013 5:35 AM
Answers
-
You can use file picker to load the XHTML file and display it. File picker will get the StorageFile object and then read the string in it. Please take a look of this sample to use File picker
http://code.msdn.microsoft.com/windowsapps/File-picker-app-extension-0cb95155"Build action" property which is used to copy the file into install folder. If we can get the file object. We need not that property.
Best regards,
JesseJesse Jiang
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Proposed as answer by Jesse Jiang Monday, May 20, 2013 7:36 AM
- Marked as answer by Jesse Jiang Wednesday, May 22, 2013 6:32 AM
Friday, May 17, 2013 5:53 AM -
Hi,
I tested your project. I found that the file does not copy to the app folder.
You should Right Click testXHTML.xhtml -> properties -> Build Action -> select Content.
Also, the install folder should be
var XHTML= await Package.Current.InstalledLocation.GetFileAsync(@"Assets\testXHTML.xhtml");
//var XHTML = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("nav.xhtml");
Blankwebview.NavigateToString(await Windows.Storage.FileIO.ReadTextAsync(XHTML));
Not the local folder.Best regards,
Jesse
Jesse Jiang
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Edited by Jesse Jiang Friday, May 10, 2013 7:40 AM
- Proposed as answer by Jesse Jiang Monday, May 20, 2013 7:36 AM
- Marked as answer by Jesse Jiang Wednesday, May 22, 2013 6:32 AM
Friday, May 10, 2013 7:24 AM
All replies
-
Hi,
I tested your project. I found that the file does not copy to the app folder.
You should Right Click testXHTML.xhtml -> properties -> Build Action -> select Content.
Also, the install folder should be
var XHTML= await Package.Current.InstalledLocation.GetFileAsync(@"Assets\testXHTML.xhtml");
//var XHTML = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("nav.xhtml");
Blankwebview.NavigateToString(await Windows.Storage.FileIO.ReadTextAsync(XHTML));
Not the local folder.Best regards,
Jesse
Jesse Jiang
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Edited by Jesse Jiang Friday, May 10, 2013 7:40 AM
- Proposed as answer by Jesse Jiang Monday, May 20, 2013 7:36 AM
- Marked as answer by Jesse Jiang Wednesday, May 22, 2013 6:32 AM
Friday, May 10, 2013 7:24 AM -
Yes, I know that. From assets folder. It loads correctly, but if XHTML files are in local folder then it's not working. Use only XHTML files from this link, please ignore the project. So I request you to create new project and put those XHTMLs in local folder & then tell me.Friday, May 10, 2013 8:38 AM
-
Hi,
I tested this and the result is the same. We can set a breakpoint at
await Windows.Storage.ApplicationData.Current.LocalFolderWhen Visual Studio break it, we can see the path in LocalFolder. It should be like this
C:\\Users\\User-name\\AppData\\Local\\Packages\\App-GUID\\LocalStateOpen that folder and copy your XHTML file into it.
Best regards,
JesseJesse Jiang
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.Wednesday, May 15, 2013 8:37 AM -
@Jesse Jiang
Hi,
Thanks. It will help me,
Then now itself I will go for Storage Folder, I will change my code.I want to know is there is any possible change the "build action" Property of XHTML file to Content by programmatic.
If I load XHTML files from my Storage folder how can I change the property.
devendra
- Edited by GDEVENDRAK Thursday, May 16, 2013 6:31 AM
Thursday, May 16, 2013 5:26 AM -
No, you can not do it in codes. The install folder is read-only ,we can not create a file in runtime.
If your XHTML come from website, you can download it first in the localstate and use it.
Best regards,
JesseJesse Jiang
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.Thursday, May 16, 2013 5:43 AM -
Ok, My intention is to convert the zip file(html/xhtml files) from any Document folder(pictures Library) to my storage folder.
From there Storage folder i want to load.
For my issue is there is any possible way to Change property of XHTML filedevendra
Thursday, May 16, 2013 6:19 AM -
You can use file picker to load the XHTML file and display it. File picker will get the StorageFile object and then read the string in it. Please take a look of this sample to use File picker
http://code.msdn.microsoft.com/windowsapps/File-picker-app-extension-0cb95155"Build action" property which is used to copy the file into install folder. If we can get the file object. We need not that property.
Best regards,
JesseJesse Jiang
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Proposed as answer by Jesse Jiang Monday, May 20, 2013 7:36 AM
- Marked as answer by Jesse Jiang Wednesday, May 22, 2013 6:32 AM
Friday, May 17, 2013 5:53 AM -
OK.
I will definitely go through your sample.Let me complete the work now & I will embedded with that sample.
Thanks.devendra
Saturday, May 18, 2013 4:38 AM