Avatar of JAruchamy
JAruchamy
Flag for United States of America asked on

File Access Permission Denied...

Hi,

I have ASP.NET page which is on Server1 and is trying to access a text file from a folder in Server2.

1. The ASP.Net code sits in a virtual directory on the IIS.

2. There is another virtual directory in the IIS which points to a location on the Server2 "\\Server2\Foldery\". I use this virtual directory and do Server.MapPath and get the loaction from this virtual directory. The path returned is right.

3. When I do a File.Exists(Path) it returns false, even though the file exsits on the Server2.

4. Can somebody help with the permissions that I have to give for the

a. Virtual Directory hosting the ASP.Net page. b. Virtual Directory poiting to the Server2. c. Folder on the Server2.

Thanks,
Jay
ASP.NETMicrosoft IIS Web ServerWindows Server 2003

Avatar of undefined
Last Comment
JAruchamy

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Meir Rivkin

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
JAruchamy

ASKER
Hi Sedgwick,

When I try FileStream fs = new FileStream(fromFile, FileMode.Open);

I get Access to the path "\\Server2\folder1\file.txt" is denied error.
Meir Rivkin

what's the exception?
Meir Rivkin

i assume it fails because the ASPNET user doesn't have the permission to access the file.
goto the folder \\Server2\folder1\, Right Click -> Properties->Security ->Edit->Add , add everyone user to permission table.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
JAruchamy

ASKER
I get a "unauthorizedaccessexception". I used Procmon.exe on the Server2 where the file is. Process monitor reports no hits from outside. So, it seems like the call from the Server1 is blocked by the IIS itself.
JAruchamy

ASKER
I created a new virtual directory and moved all the files there. Boom it worked.... thnx sedgwick for you answers though...