简体   繁体   中英

Classic ASP + IIS 7 Writing a file to a network drive

I have Classic ASP 2 websites on an Windows 2008 IIS 7 install. website1.com and website2.com. Both are serving the same website from one folder: C:\\Webs\\website\\

website1.com has been in operation for 6 years and in the app it can write files to a network share; \\wdc\\SharedFiles\\assets\\docs\\ All the proper permissions are set as it has been reading and writing files for years.

I recently added website2.com. The website is serving from the same diretory. I need it to be able to write to that same share. The problem is, website2.com gets "Write to file failed." and "Permission Denied" errors.

How is this possible?

I even mocked up a simple test. Same error.:

  Dim fso, objFile
  Set fso=Server.CreateObject("Scripting.FileSystemObject")
  Set objFile=fso.CreateTextFile("\\wdc\SharedFiles\assets\docs\test.txt")
  objFile.WriteLine("hello this is test")
  objFile.Close
  Set objFile=Nothing
  Set fso=Nothing

Any ideas? I am pulling my hair out.

I figured this out on my own. So others can benefit, here it is:

  1. In IIS go to the website (website2.com) node, then select "Authentication".
  2. Make sure "Anonymous Authentication" is enabled and set it to a user.
  3. Then with the Explorer give that user read-and-write access to the share.

Not sure if this will make a difference. The only difference in my code, really, is that I'm using server.mapPath to specify path.

path = Server.MapPath ("\")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateTextFile(path & "\" & txtFileName, 2) '2 = for Writing
f.Write(txtFileContents)
f.close
set f=nothing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM