Trouble accessing ApplicationData from x-ms-webview. RRS feed

  • Question

  • I am working on an app that lets users edit their documents. When user edits a document, a html based editor is opened in another x-ms-webview. For editor to work it needs to read some files containing JSON data from disk at runtime. For that i have used following code:

    var test = 'WebEditor\\SmartDoc\\Schema.json';
                    var file = Windows.Storage.ApplicationData.current.localFolder.getFileAsync(test).then(function (e) {
                        e.openReadAsync().then(function (inputStream)
                            var reader = new Windows.Storage.Streams.DataReader(inputStream);
                            var size = inputStream.size
                            reader.loadAsync(size).then(function () {
                                var contents = JSON.parse(reader.readString(size));
                    }, function (e) {

    This code works as long as i am inside page which is running under MSAppHost user agent. Editor which is opened in x-ms-webview has different user agent "WebView" where i dont have access to "Windows" object. So, above code does not work in x-ms-webview. Can any one tell me what i am missing here? I am new to WinJS.

    • Edited by asingh86 Wednesday, January 7, 2015 1:04 PM
    Wednesday, January 7, 2015 12:58 PM


  • Hi asingh86,

    As I know you can navigate to some HTML string by navigateToString method.

    Here is the work around but I don't know if I misunderstand something.

    #1, Read your HTML string

    #2, Read your Json data and insert to the HTML string

    #3, Display the HTML in the x-ms-webview control.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 8, 2015 7:49 AM