Could someone help me understand issues related to permissions in accessing a folder on file server from ASP.NET.
I use the below -
Web Server - IIS 5.1
File Server
ASP.NET 3.5
1. I created two virtual directories in IIS in the web server. One holds the files for the a) application and the other points to b)files directory on the file server.
2. I created a new user "NEWUSER" on both the web server and the file server and added them to corresponding servers' administrators group.
3.
a) Application virtual directory has windows integrated authentication checked, anonymous authentication disabled.
b) Files virtual directory has anonymous access enabled for NEWUSER.
4.
Directory on file server has been given full security access for NEWUSER. I have also shared this directory for NEWUSER.
5.
I have below configuration defined in ASP.NET client web.config.
<pre lang="xml"><authentication mode="Windows"/>
</pre>
This is my code below.
__________________________________________________________
<pre>private void PopulateGrid()
{
try
{
DirectoryPath = @"\\[WEBSERVER]\[filesVirtualDirectory]\" + Convert.ToString(Request.QueryString["ID"]);
DirectoryInfo currentDirInfo = new DirectoryInfo(DirectoryPath);
fsItems = new List<FilesInfo>();
if (currentDirInfo.Exists)
{
foreach (FileInfo fi in currentDirInfo.GetFiles())
{
FilesInfo fInfo = new FilesInfo();
fInfo.Name = fi.Name;
fInfo.Extension = fi.Extension;
fInfo.FileLink = "//[WEBSERVER]/[filesVirtualDirectory]/" + Convert.ToString(Request.QueryString["ID"]) + "/" + fi.Name;
fsItems.Add(fInfo);
}
}
gvFiles.DataSource = fsItems;
gvFiles.DataBind();
}
catch (Exception ex)
{
ExceptionLogger.LogError(ex);
}
}</pre>
The code reads contents from directory and populates on to a grid. When I run my application on the webserver, the web server fails to list contents of the directory, no errors are produced though. When I attempt to upload a document to this folder, I receive an error - "Network Path not found". I have code written using Word interop that creates a document and saves to this folder. I get a "Access to Path denied error" on this.
When the application is run on my machine (localhost), it works. I can successfully upload / delete documents from this folder. I however get an unknown error when application attempts to save the word interop document on to this folder. The web page still refers to webserver's FilesVirtualDirectory even though it is run from localhost.
Any thoughts?
Thanks.