directory browsing works in PWS but not IIS5

Discussion in 'ASP General' started by Dan Nash, Mar 4, 2004.

  1. Dan Nash

    Dan Nash Guest

    Hi guys

    I have a page that is *supposed* to list the directories on the server.
    Here's the code...

    folderspec = server.MapPath("./images/")
    set fso = CreateObject("Scripting.FileSystemObject")
    set fold = fso.GetFolder(folderspec)
    for each subfolder in fold.subFolders
    Response.Write(subfolder.name & "<br>")
    next
    set fold = nothing
    set fso = nothing

    The code works perfectly on Win98 / PWS but causes some very odd occurances
    on XP Pro / IIS. Either it gets in a loop, and hangs the server, causing me
    to have to reset. Or it will go through the motions, I get the blue bar at
    the bottom, it goes away, says Done in the status bar, and the page hasnt
    changed. It's weird...

    I assume it's something to do with permissions but not sure?

    Any help appreciated,

    Cheers


    Dan
     
    Dan Nash, Mar 4, 2004
    #1
    1. Advertisements

  2. Dan Nash

    Pravin Patil Guest

    Hi

    Debug the application and find out where it is getting hanged

    Cheers

    Pravin Patil
     
    Pravin Patil, Mar 4, 2004
    #2
    1. Advertisements

  3. Dan Nash

    Dan Nash Guest

    Hi Pravin

    It has debug information in the file as response.writes all over the place.
    Unfortunately IIS doesnt seem to run the file at all, ie you click the link
    to it and it does the blue bar and doesnt change the page. Therefore I have
    no idea where it's getting to unfortunately.

    Cheers


    Dan
     
    Dan Nash, Mar 4, 2004
    #3
  4. Dan Nash

    Dan Nash Guest

    provide a link to what?
     
    Dan Nash, Mar 4, 2004
    #4
  5. Dan Nash

    Roland Hall Guest

    in message : Hi Pravin
    :
    : It has debug information in the file as response.writes all over the
    place.
    : Unfortunately IIS doesnt seem to run the file at all, ie you click the
    link
    : to it and it does the blue bar and doesnt change the page. Therefore I
    have
    : no idea where it's getting to unfortunately.

    That's gonna' be tough to do. You didn't provide a link. (O:=

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Mar 4, 2004
    #5
  6. Dan Nash

    Roland Hall Guest

    in message : folderspec = server.MapPath("./images/")
    : set fso = CreateObject("Scripting.FileSystemObject")
    : set fold = fso.GetFolder(folderspec)
    : for each subfolder in fold.subFolders
    : Response.Write(subfolder.name & "<br>")
    : next
    : set fold = nothing
    : set fso = nothing

    Will this make a difference?

    This works for me:

    <%@ Language=VBScript %>
    <%
    Option Explicit
    Response.Buffer = True

    Dim folderspec, fso, f, fc, fl
    folderspec = Server.MapPath("/images")
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.GetFolder(folderspec)
    Set fc = f.SubFolders
    For each fl in fc
    Response.Write(fl.name & "<br />")
    Next
    Set fso = nothing
    Set f = nothing
    Set fc = nothing
    %>

    My images directory is one off the web root: http://domain.com/images

    HTH...

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Mar 4, 2004
    #6
  7. Dan Nash

    Roland Hall Guest

    : provide a link to what?
    :
    : > : Unfortunately IIS doesnt seem to run the file at all, ie you click the
    : > link
    : > : to it and it does the blue bar and doesnt change the page. Therefore I
    : > have
    : > : no idea where it's getting to unfortunately.

    We cannot see what you're seeing. You said, you click the link.
     
    Roland Hall, Mar 4, 2004
    #7
  8. Dan Nash

    Dan Nash Guest

    Hi Roland,

    Fraid it doesn't. I've just tried your code and the same thing happens.
    However, the first time forgot the <% and it just presented me with a load
    of text (the code) on the page. So I know it's actually loading the page.

    Can I ask how your image directory's permissions are setup? I've set my
    directories to enable read/write/directory browsing, but still no luck.

    Cheers


    Dan
     
    Dan Nash, Mar 4, 2004
    #8
  9. Dan Nash

    Jeff Cochran Guest

    Take a look at:

    http://www.devguru.com/Technologies/vbscript/quickref/folderscollection.html

    Jeff
     
    Jeff Cochran, Mar 4, 2004
    #9
  10. Dan Nash

    Dan Nash Guest

    Ahhh.. :eek:) No I was just trying to explain what happens when the link is
    clicked. The site is on my local XP box.

    Sorry for any confusion!! :eek:)

    Cheers


    Dan
     
    Dan Nash, Mar 4, 2004
    #10
  11. Dan Nash

    Dan Nash Guest

    Hi Jeff

    Thanks for that. Have had a look and tried the code, and I still get the
    same problem. Page just doesn't display (it stays on the page u were on).
    Makes no sense....
     
    Dan Nash, Mar 4, 2004
    #11
  12. Dan Nash

    Roland Hall Guest

    in message : Ahhh.. :eek:) No I was just trying to explain what happens when the link is
    : clicked. The site is on my local XP box.

    Ah, I was wrong. It wouldn't be difficult, it would be impossible! (O:=

    : Sorry for any confusion!! :eek:)

    I've been confused for years.
     
    Roland Hall, Mar 4, 2004
    #12
  13. Dan Nash

    Roland Hall Guest

    in message : Fraid it doesn't. I've just tried your code and the same thing happens.
    : However, the first time forgot the <% and it just presented me with a load
    : of text (the code) on the page. So I know it's actually loading the page.
    :
    : Can I ask how your image directory's permissions are setup? I've set my
    : directories to enable read/write/directory browsing, but still no luck.

    Hi Dan...

    Ok, try this link. This is the code I posted earlier.
    http://guysare.us/lab/folders.asp

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Mar 4, 2004
    #13
  14. Do you know for sure if the local IUSR_<machinename> account has the
    permissions to perform this action on that folder?
     
    Phillip Windell, Mar 4, 2004
    #14
  15. Dan Nash

    Roland Hall Guest

    in message
    : "Dan Nash" wrote in message
    : : Fraid it doesn't. I've just tried your code and the same thing happens.
    : : However, the first time forgot the <% and it just presented me with a
    load
    : : of text (the code) on the page. So I know it's actually loading the
    page.
    : :
    : : Can I ask how your image directory's permissions are setup? I've set my
    : : directories to enable read/write/directory browsing, but still no luck.
    :
    : Hi Dan...
    :
    : Ok, try this link. This is the code I posted earlier.
    : http://guysare.us/lab/folders.asp

    If you're running this on XP, aren't you running IIS 5.1? You are loading
    this from the virtual path and not from the physical path, right? I'm
    asking because you said you ran it and saw code. It's all ASP VBScript, you
    shouldn't see any code at all in the browser.

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Mar 4, 2004
    #15
  16. Dan Nash

    Dan Nash Guest

    Hi Roland,

    Thanks. Right, let's see if we can get some sense out of this...

    The code you sent me I tried, and it works on PWS but not on IIS. Very odd.
    I am indeed running IIS 5.1 on XP as a local server, so there's nothing else
    involved. and all the directories have the "directory browsing" enabled in
    IIS. They don't however have "anonymous access" setup, although I have tried
    this and it makes no difference.

    As far as I can tell, it's either something to do with permissions, or the
    location of the folder and server.mappath(). Im trying to display a list of
    the folders in the following folder on the C drive...

    c:\inetpub\wwwroot\darts\library\documents

    ... im doing it from an asp file in the \library directory, so, i would
    assume mappath("./") would give me a list of what's in library, and
    mappath("./documents/") or mappath("/documents/") would get me into the
    folder I actually want. However. I've tried every possible combination I can
    think of, to no avail.

    Something else that might have something to do with it... I've never been
    able to access the server from the rest of the network, like i can with PWS.
    If i go to IE and do http://development/ (the machine name) I get nothing
    and if i go to 10.0.0.1 (the xp machines net addy) i get an "unauthorized"
    page. THAT makes me think the permissions are stuffed somewhere.......

    Hope any/all/some of that is useful to you in solving this problem.

    Thanks for your perciverance!


    Dan
     
    Dan Nash, Mar 5, 2004
    #16
  17. Dan Nash

    Dan Nash Guest

    as far as I can tell, yes. all directories have "directory browsing"
    enabled, and at the moment they all have anonymous access, although that
    doesnt seem to make a difference.

    If you read my earlier post (today) in reply to Roland, there is a
    permissions issue in that I cant access the IIS 5.1 server from any other
    machine on my network.

    Cheers


    Dan



     
    Dan Nash, Mar 5, 2004
    #17
  18. Dan Nash

    Roland Hall Guest

    in message : Hi Roland,

    Hi Dan... great information.

    : Thanks. Right, let's see if we can get some sense out of this...
    I'm ready! (O:=

    : The code you sent me I tried, and it works on PWS but not on IIS. Very
    odd.
    : I am indeed running IIS 5.1 on XP as a local server, so there's nothing
    else
    : involved. and all the directories have the "directory browsing" enabled in
    : IIS.
    You do not need nor do you want directory browsing. This will make all of
    your server-side code available to anyone unless you have a default document
    in the subdirectory. We can go over that later.

    : They don't however have "anonymous access" setup, although I have tried
    : this and it makes no difference.
    You set the anonymous user access at the site level in Internet Services
    Manager. It is located on the Directory Security tab, click edit under
    Anonymous Access and Authentication Control, then click to check Anonymous
    Access to make sure it is enabled. Click Edit under that heading and make
    sure the user is iusr_computername (mine is iusr_fs1) and check to allow
    IIS, if it is not already checked, to control the password. It makes this
    change in the user settings for the iusr_computername account.

    If any of these are not set, I need to know which ones because if the
    iusr_computername password has been changed, you may have to edit it the
    first time but don't worry about it for now.

    : As far as I can tell, it's either something to do with permissions, or the
    : location of the folder and server.mappath(). Im trying to display a list
    of
    : the folders in the following folder on the C drive...
    :
    : c:\inetpub\wwwroot\darts\library\documents
    :
    : .. im doing it from an asp file in the \library directory, so, i would
    : assume mappath("./") would give me a list of what's in library, and
    : mappath("./documents/") or mappath("/documents/") would get me into the
    : folder I actually want. However. I've tried every possible combination I
    can
    : think of, to no avail.

    The permissions of the anonymous user account is one area and you have a
    misunderstanding here.
    The web root is:
    virtual: /
    physical: c:\inetpub\wwwroot

    Server.MapPath works from the web root unless you specify the parent
    directory (..).
    So, using your paths listed above, let's make some corrections.
    .. is a representation of the current directory.
    ... is a representation of the parent directory.
    Server.MapPath works from either the web root, or from a directive (.) or
    (..).
    .. and .. are relative to the current directory and not relative from the
    root.
    Since / is always the web root, if you always start here, you always know
    where you are. I never use current or parent directives.
    So, if the documents directory physical path is:
    c:\inetpub\wwwroot\darts\library\documents
    .... then the virtual path is:
    /darts/library/documents
    To use Server.MapPath from the relative root, you address it as:
    Server.MapPath("/darts/library/documents")
    If you do it this way, you do not have to know which subdirectory you're
    currently in.
    For this to work:
    Server.MapPath("./documents")
    .... /darts/library has to be your current subdirectory.

    : Something else that might have something to do with it... I've never been
    : able to access the server from the rest of the network, like i can with
    PWS.
    : If i go to IE and do http://development/ (the machine name) I get nothing
    : and if i go to 10.0.0.1 (the xp machines net addy) i get an "unauthorized"
    : page. THAT makes me think the permissions are stuffed somewhere.......

    Yes, this has to do with anonymous user access.

    : Hope any/all/some of that is useful to you in solving this problem.
    We're getting there.

    : Thanks for your perciverance!
    You're welcome.

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Mar 5, 2004
    #18
  19. Dan Nash

    Dan Nash Guest

    Hi again,

    Thanks for the advice - I've turned directory browsing off completely on all
    directories now. My initial thought was that this was required to allow the
    FSO to work, but since it isn't.. byebye!

    I have set up anonymous access on all the directories, with the default
    password and the control password thing checked. My machine is called
    "!USR_DEVELOPMENT", and it still seems to be working fine locally. Still
    can't access the machine from anywhere else though. I should point out that
    "integrated windows authentification" is also checked.

    But.. back to the main problem of directory browsing. Still can't get it to
    work. Have tried the mappath's you suggested, but it still just sits there
    for ages. It's almost like it in a semi-infinite loop, but when it ends it
    hasn't changed the page. ANd as I said, can't add debug messages cos they
    can't display.

    tearing my hair out now!!

    Thanks


    Dan
     
    Dan Nash, Mar 5, 2004
    #19
  20. Dan Nash

    Roland Hall Guest

    in message : Thanks for the advice - I've turned directory browsing off completely on
    all
    : directories now. My initial thought was that this was required to allow
    the
    : FSO to work, but since it isn't.. byebye!
    :
    : I have set up anonymous access on all the directories, with the default
    : password and the control password thing checked. My machine is called
    : "!USR_DEVELOPMENT", and it still seems to be working fine locally. Still
    : can't access the machine from anywhere else though. I should point out
    that
    : "integrated windows authentification" is also checked.

    If you right click on the default web site and set it there, you don't have
    to do it anywhere else.

    : But.. back to the main problem of directory browsing. Still can't get it
    to
    : work. Have tried the mappath's you suggested, but it still just sits there
    : for ages. It's almost like it in a semi-infinite loop, but when it ends it
    : hasn't changed the page. ANd as I said, can't add debug messages cos they
    : can't display.
    Well that's because we apparently still have a permissions issue or
    something is blocking it.
    Do you have the XP firewall enabled?

    : tearing my hair out now!!
    That's never a good idea.

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Online Support for IT Professionals -
    http://support.microsoft.com/servicedesks/technet/default.asp?fr=0&sd=tech
    How-to: Windows 2000 DNS:
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;308201
     
    Roland Hall, Mar 5, 2004
    #20
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.