ASP Classic can not access Virtual Directory using FileSystemObject on IIS 7

asp-classiciis-7permissionsvirtual-directory

I have a Classic ASP website which we have moved from IIS 6 to Win2k8 and IIS 7. Within the website folder structure, is a Virtual Directory called Products containing JPGs that are physically stored elsewhere on the same server.

Within a web browser, any of the Product JPGs display correctly on the page. E.g. http://www.MySite.com/images/poducts/widget.jpg works a treat.

However, this folder is unavailable when trying to access it in ASP code, using the FileSystemObject – all other files/folders are there except the Virtual Directory. Here is an example ASP code snippet:

Set objFSO = Server.CreateObject( "Scripting.FileSystemObject" )
Set objBaseFolder = objFSO.GetFolder( Server.Mappath( "../../Images" ) )
For Each objFolder In objBaseFolder.SubFolders  
    Response.Write( objFolder.Name & "<br>" )
Next
Set objFolder = Nothing
Set objBaseFolder = Nothing
Set objFSO = Nothing

Additionally, Persit's ASPJpeg Com Object has no problem opening and saving JPG files to/from this Virtual Directory from ASP code.

In IIS7, the website has an Application Pool, and I've tried all manner settings for its identity to no avail. I have also tried applying various security settings (IUSR_, Network Service, et al) to the physical folder that the Virtual Directory points to – even granting full control to "Everyone" at one point.

It really seems like the ASP process does not have permission to Virtual Directories. If anyone has and idea on how to solve this problem then I'd be most greatful.

Best Answer

Using FileSystemObject to do this is never going to work because it only works on the physical file system. It does not know about or understand virtual directories - this aspect of your site is managed entirely by IIS.

It is not a question of permissions it is a question of the directory not physically being there so browsing the physical file system will never see it

IIS manages virtual directories:

  • Navigating to an image in your browser works because IIS automatically maps the virtual path to the appropriate physical path.
  • Using AspJpeg works most likely because it uses calls to Server.MapPath to resolve the given path into a physical path

This cannot be an issue of permissions since you stated yourself that AspJpeg can read and write to the virtual directory fine plus you can access it through your browser fine.