locked
Why can a relative css file not be found?

    Question

  • I have this folder structure:

    /html
      /settings
        about.html
        about.css
        about.js


    My about html looks like this:

    <head>
        <meta charset="utf-8"/>
        <script src="about.js"></script>
        <link href="about.css" rel="stylesheet"/>
        <title> </title>
      </head>

    However, the css is not loaded. Its only loaded if specify its full path as "/html/settings/about.css" What about that? The same html works just fine in the browser.


    • Edited by phil_ke Monday, October 8, 2012 4:12 PM
    Monday, October 8, 2012 4:11 PM

Answers

  • They seem correct:

    <link href="ms-appx://myapp.app/html/settings/about.css" rel="stylesheet"></link>
    </link>
    <script src="ms-appx://myapp.app/html/settings/about.js" type=""></script>

    Yet VS2012 prints

    The application couldn't resolve ms-appx://myapp.app/html/about.css because of this error: RESOURCE_NOT_FOUND.
    The application couldn't resolve ms-appx://myapp.app/html/about.css because of this error: RESOURCE_NOT_FOUND

    Update: It seems the styles are loaded anyway now. But the error printout in the log remains.

    • Edited by phil_ke Monday, October 8, 2012 4:50 PM
    • Marked as answer by Dino He Friday, October 12, 2012 9:30 AM
    Monday, October 8, 2012 4:48 PM

All replies

  • Hi, phil_ke,

    Specially when you are using navigator.js, that loads fragments inside a defaul.html, the app seems to load all the js refered on the fragment that is been loaded like BASE + address:

    ms-appx://packageid/pages/teste/test.js

    I beleive that because of this,

    If you add a relative address, it will be concated with the ms-appx://packageid and so lose the reference.

    Monday, October 8, 2012 4:24 PM
  • Thing is, the js file is loaded correctly, just the css not. Seems like a bug.
    Monday, October 8, 2012 4:39 PM
  • Oh, well, have you checked in Visual Studio using the DOM Explorer?

    Could you check how is the final processed path, inside the <head></head> tag.

    Monday, October 8, 2012 4:45 PM
  • They seem correct:

    <link href="ms-appx://myapp.app/html/settings/about.css" rel="stylesheet"></link>
    </link>
    <script src="ms-appx://myapp.app/html/settings/about.js" type=""></script>

    Yet VS2012 prints

    The application couldn't resolve ms-appx://myapp.app/html/about.css because of this error: RESOURCE_NOT_FOUND.
    The application couldn't resolve ms-appx://myapp.app/html/about.css because of this error: RESOURCE_NOT_FOUND

    Update: It seems the styles are loaded anyway now. But the error printout in the log remains.

    • Edited by phil_ke Monday, October 8, 2012 4:50 PM
    • Marked as answer by Dino He Friday, October 12, 2012 9:30 AM
    Monday, October 8, 2012 4:48 PM
  • Hi phil_ke, I tried to reproduce here, but for me both works fine (relative and absolute path).

    I'm just doing some tests and trying to figure out what could be the problem. Any updates, I talk to you.

    Maybe a deployment problem... Have you tried to Clean and re-deploy your solution?
    • Edited by geovanneb Monday, October 8, 2012 5:00 PM
    Monday, October 8, 2012 4:59 PM
  • Thanks for trying. Do you get the error message in the Debugger out? I have to say this is a settings page I am trying to display. Maybe it has to do with how settings pages are loaded.
    Tuesday, October 9, 2012 7:30 AM
  • Hi phil,

    I tried with the settings pages. It works fine for me (css and js).

    There are no error messages in the Debugger out...

    Tuesday, October 9, 2012 4:10 PM