I'm attempting to send a file to the browser that is located on a remote host (via UNC).
The web app is running both under impersonation and an App Pool with a user that has full access to the remote host's UNC directory (via matching credentials).
I can read and write files with no issues on the UNC path using the System.IO object's File.Copy. However, when I attempt
Dim file As System.IO.FileInfo = New System.IO.FileInfo([UNCFilePath])
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name.Replace(" ", "_"))
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
I get
System.IO.IOException: Logon failure: unknown user name or bad password
If I copy the file via File.CopyTo to a local directory and do a writefile from there, it works.
My main question, outside of solution to this problem, is why does File.Copy work and File.Response not work? Aren't they both using System.IO?