locked
Can I use MSApp.addPublicLocalApplicationUri to navigate to html pages that live in my apps local data directory?

    Question

  • I have an app that has html pages stored away in the apps local data directory (ms-appdata://local/)

    I would like to be able to display that html in an iframe so I thought I might be able to use MSApp.addPublicLocalApplicationUri('ms-appdata://local/*')

    This dosent seem to work and it throws the same error I have seen before adding "addPublicLocalApplicationUri" call


    "The app can’t use script to load the ms-appdata://local/Page001.html url because the url launches another app. Only direct user interaction can launch another app. Visual Studio is not currently attached to a script debug target that supports script diagnostics."

    Is this possible at all? Thanks!

    Tuesday, April 30, 2013 10:55 PM

Answers

  • Sorry, that's not going to be possible.  Store apps are not allowed to rely on other applications installed on the local machine.  Only remote servers are allowed.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, May 03, 2013 2:58 PM
    Moderator

All replies

  • http://msdn.microsoft.com/en-us/library/windows/apps/Hh780594.aspx

    Does specifically naming the page to add work?  How about leaving off the ms-appdata:/// prefix?


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, May 01, 2013 2:10 PM
    Moderator
  • I tried this

    MSApp.addPublicLocalApplicationUri("local/*");

    But I get the same error. Im starting this think this is not possible after reading this here: "To refer to such content, you must use the scheme "ms-appdata:", with the path to the file within your ApplicationData local storage. Note that, for security reasons, you cannot navigate to HTML you have downloaded to this location and you cannot run any executable or potentially executable code, such as script or CSS. It is intended for media such as images or videos and the like." from http://msdn.microsoft.com/en-us/library/windows/apps/hh781215.aspx

    Wednesday, May 01, 2013 6:04 PM
  • It looks like you are correct.  However, have you considered writing the HTML to a string, then loading into the document body?


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, May 01, 2013 8:53 PM
    Moderator
  • I have and have done that. I also have to rewrite all the paths to images from "images/bla.png" to "ms-appdata://local/images/bla.png". I also needed to embed all the css instead of linking to it (because of the limitations as mentioned in my last post). The big problem now is fonts. The html files have custom fonts but I cant link to them of course. So my next thought was convert the fonts to base64 and embed them. Well unfortunately within the local context data urls are disabled for fonts as called out here: http://msdn.microsoft.com/en-us/library/windows/apps/hh465373.aspx

    So now Im officially blocked. Cant link to fonts + cant embed fonts = no fonts.

    The only option I see is to package the fonts with the app. But thats not really an option because these html files that are downloaded could have any number of different types of custom fonts.

    Am I really blocked here? Is there a way to link to non-media data (css/fonts) from the local context?

    Wednesday, May 01, 2013 9:27 PM
  • Maybe you ought to consider a different strategy, such as saving the content to a web server.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, May 02, 2013 5:30 PM
    Moderator
  • I have considered that but these are suppose to be available for offline access. I dont know if this is possible but one idea that someone mentioned is to create a web server proxy on the system that points to the local storage directory and then create a frame thats in a web context that access content though the proxy. I dont know if its possible to package a web server that runs when the app is opened. Is something like that possible?
    Thursday, May 02, 2013 5:36 PM
  • Sorry, that's not going to be possible.  Store apps are not allowed to rely on other applications installed on the local machine.  Only remote servers are allowed.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, May 03, 2013 2:58 PM
    Moderator
  • Friday, May 03, 2013 6:18 PM