Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • pat 124 posts 346 karma points
    Feb 06, 2013 @ 15:46
    pat
    0

    GetXmlDocumentByUrl - from restricted anonymous access folder

    Hi all , not sure this is doable or not, I need to create a folder under root of the web site ,and restric access to annonymous users. I would like to save xml file in that folder , then create xslt macro to read data from that xml file.

    but if some one try to access url directly  should not be accessible.

    is this possible ? I am using Umbraco 4.7.1.1

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Feb 12, 2013 @ 22:46
    Chriztian Steinmeier
    100

    Hi pat,

    I havent tried this, so can't tell you if the security aspect of it works, but as far as I know, .config files are not accessible from direct HTTP requests (i.e. from a browser). So name your file .config instead of .xml and use the built-in document() function to read it:

    <xsl:variable name="restrictedFileRootElement" select="document('../ssshhh-secretfolder/rocket-science.config')/*" />
    
    <!-- Display some data from the file -->
    <xsl:template match="/">
        <p>Root element in file is: &lt;<xsl:value-of select="name($restrictedFileRootElement)" /></p>
        <p>Number of children: <xsl:value-of select="count($restrictedFileRootElement/*)" /></p>
    </xsl:template>

    /Chriztian

  • pat 124 posts 346 karma points
    Feb 13, 2013 @ 17:31
    pat
    0

    wow , that's worked ... brilliant

    thanks

  • Petr Snobelt 923 posts 1534 karma points
    Feb 14, 2013 @ 08:44
    Petr Snobelt
    0

    In asp.net your secure data should be placed inside App_Data folder. Data in this folder is not accessible from website, only asp.net app can access it.

    It is also reason to umbraco put it's data here :-)

    Petr

     

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Feb 14, 2013 @ 22:12
    Chriztian Steinmeier
    0

    @Petr: You are of course totally right about that - thanks! :-)

    So we should be able to change the variable to this instead:

    <xsl:variable name="restrictedFileRootElement" select="document('../App_Data/rocket-science.xml')/*" />

     

    /Chriztian

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies