Reading a file into a buffer from in asp.net: error "Logon failure: unknown user name or bad password."
Posted on 2004-10-06
We are facing an interesting problem.
We have some tiff image files located on a remote shared folder, say
Only specific logins are given access to this folder.
Now, on my webpage, if I place an image control, and set its src value as follows:
myImg.Src = @"\\172.23.45.66\Shared\Images\tmpin.jpg";"
Then the code works and the image is displayed.
But, If we try to read the image into a buffer as follows:
byte buf = null;
System.IO.FileStream fs = new System.IO.FileStream(myImg.Src, System.IO.FileMode.Open, System.IO.FileAccess.Read);
buf = new byte[fs.Length];
fs.Read(buf, 0, buf.Length);
then we get the following error:
"Logon failure: unknown user name or bad password. "
It is very important that we load the file into a buffer.
So, can some one suggest what could be the problem and how it can be solved?
Note that it is not possible for us to create additional shares or virtual Web folders for the file directory, because the address can be anything that the user has rights to: it is not necessarily one single folder.
So, we are looking for a generic solution to load a file into a buffer from an ASP .net page if the current windows user has rights to access the folder.
Looking forward to your help.