I have a legacy web app, which has a HTTPHandler to give access to a set of files by checking permissions in database.
In development it works OK.
But in production, it works only in localhost. Every another computer that try to access file (and should read it) throws an exception:
Access to the path 'G:\Sites\Portal\Portals\0\attachments' is denied.
At line:
Dim bufferArquivo As Byte() = IO.File.ReadAllBytes(request.PhysicalPath)
It denies access to folder where file is located, but I've checked it has full permissions to Everyone.
I'm not using impersonation, so I'm thinking if could be it. If yes, how can I implement?
It happens after migrate website from IIS6 to II7. (works on iis6, does not in iis7)
I don't know exactly happens, but before migrating to IIS7, request.PhysicalPath
was returning full filename path (full path + filename). After, it was returing only the folder containing the file (full path). I had to insert filename to request.PhysicalPath
to work as nefore.
Dim filename As String = request.Path.Substring(request.Path.LastIndexOf("/") + 1)
Dim bufferArquivo As Byte() = IO.File.ReadAllBytes(request.PhysicalPath + "\" + filename)