Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Permissions issue - can't programmatically delete files on the server

Thread Tools

Permissions issue - can't programmatically delete files on the server

Posts: n/a
I've got a permissions issue I can't figure out; I've been searching
for info and haven't found anything to help me.

I'm testing an ASP.Net 2.0 application that allows a user to upload
files, and delete them later. The upload works fine; the file gets
saved to the proper directory. The delete does not. Here's the info:

* * *

Access to the path 'F:\My App\Path\SubDir\materials\' is denied.

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the
path 'F:\Terra Cognita\Operations\Projects\IRC
E-zine\ProjectFiles\NewWebPublisher\webInterface\ads \materials\' is

ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request identity.
ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS
5 or Network Service on IIS 6) that is used if the application is not
impersonating. If the application is impersonating via <identity
impersonate="true"/>, the identity will be the anonymous user
(typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer,
choose "Properties" and select the Security tab. Click "Add" to add the
appropriate user or group. Highlight the ASP.NET account, and check the
boxes for the desired access.

* * *

It's the call to System.IO.File.Delete that causes the exception.

Seems straightforward enough. Except that when I check the folder's
permissions in Windows Explorer (I'm testing on my local machine),
"ASP.NET Machine Account" and "Internet Guest Account" both have full
control on that specific directory. (I started off by giving them
"Delete Subfolders and Files" permissions on that directory, but when
that didn't work...)

Can *anyone* help me figure this out? It's driving me to drink.

Windows 2000, IIS 5.0, Microsoft .NET Framework Version:2.0.50727.42;
ASP.NET Version:2.0.50727.42.


Reply With Quote
Posts: n/a
that sounds like a ACL permission problem. When the file is uploaded to
that directory, check the permissions on that file and see if they have
the same permissions as the containing folder, if you are in a domain,
you might try setting your identity to a domain user (just for
testing purposes) and see if you can delete it then, also if you are
uploading the file, ensure that you are disposing the filehandle (if
any) because this could cause a problem as well.

Reply With Quote
Posts: n/a
Few Tips to debug
1. Try to delete another file from the dir that dir.
2. Check the permissions on file
3. check the ACL permissions on the folder
4. identity to some domain user rather than anonymous


Reply With Quote
Posts: n/a
please read 1 as
try to delete another file from that directory that is manually created.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
In-depth documenation on User Permissions, Group Permissions, ACLs, DCLs etc. Curt K ASP .Net 0 11-03-2006 04:54 PM
Add/Remove permissions to folders programmatically Codex Twin ASP .Net 1 01-08-2005 01:35 AM
ASPX file returning obscur runtime error - after changing permissions to a subweb (.net app) to different permissions than on its parent ? Isabelle ASP .Net 0 08-11-2004 02:04 PM
Re: Permissions - giving "everyone" full permissions is bad ? Scott Allen ASP .Net 0 07-13-2004 08:54 PM
Retrieve printer permissions programmatically ARaman C++ 1 10-23-2003 03:34 AM