views:

77

answers:

2

We have a .NET web application installed on our server at the location: C:\Inetpub\fmtool\

One of our utilities uploads a file to a subfolder of the installed directory.

We create the folder structure for this uploaded file programmically to ensure the folder structures integrity. This works just fine.

However during the actual file copy (using an asp file upload control) we get a permissions error saying access is denied.

I have ensured that the user-account running the application on the server has full control of the file system (in development of course) and we still get this access denied error.

FileUpload seems straight forward:

fuiUpload.SaveAs(path);

Were "path" is pulled from the Web.Config

<add key="ActualsImportPath" value="C:\Inetpub\fmtool\ActualsImport\Alpha"/>

If we were running this local we would need the full qualified server information in the beginning correct?

For example:

<add key="ActualsImportPath" value="\\SERVER-NAME\c$\blah"/>

UPDATE:

After inspecting my code. I found a glaring error. I did not actually have the full "path" variable set at the time I was attempting to process the SaveAs(). A simple mistake caused so much trouble. Thank you all for the help. See code below if interested

Before:

if (fuiUpload.HasFile)
{
    // Did not have the complete path here.....
fuiUpload.SaveAs(path);

// Run the importer
switch (rblImportType.SelectedValue)
{
 case "0": 
 path += @"\Nightly Costing\" + DateTime.Now.ToString("yyyyMMdd") + "-NightlyCosting.csv";
 break;

After:

if (fuiUpload.HasFile)
{
// Run the importer
switch (rblImportType.SelectedValue)
{
 case "0": 
 path += @"\Nightly Costing\" + DateTime.Now.ToString("yyyyMMdd") + "-NightlyCosting.csv";
    fuiUpload.SaveAs(path);
 break;
A: 

If this is an IIS 6.0 server, you need to give the Network Services write/create permission on the folder.

Note that the "Network Services" identity is the default for the web site. Check the Identity tab for the application pool associated with the application folder if the fix above does not work.

Jersey Dude
Tried this.. Unfortunately it did not work... Thanks for the answer though
Mike Fielden
A: 

Hi Mike,

If I understand your update, you've solved your issue, correct? i did want to make a comment on setting permissions for the Network User account. Giving file CRUD access to this account is generally not a best practice. That account has too much power to be given that kind of access. I recommend creating an account for the sole purpose of accessing the file system from your web apps. You can then use impersonation to have the code that accesses file system do so under the guise of that account.

Hope you've got everything working well.

Dave Ranck www.daveranck.com [fitnessforeveryman.com][2]

Dave Ranck