Trouble deleting file from server - IIS Worker Process the culprit

In my web application, I am trying to delete a file from the server and it says permission denied, using: Scripting.FileSystemObject
   fs.DeleteFile(filename),True

in IIS I have the Anonymous User Identity set to the Application Pool Identity.

The folder for the files has granted full advanced permissions, including delete, for these users:
IUSR
IIS_IUSRS
DefaultAppPool

Once I set the settings on the folder and propagate all via replace all child object permissions...

I can delete an existing file.
Then I upload a new one.
Then I replace the new one.
Then I delete the new one. And I get the error.

So I went to the server itself and selected the file in the file directory and tried to delete and get this error:
The action can't be completed because the file is open in IIS Worker Process
Close the file and try again

What is the IIS Worker Process of which we speak and why is it doing it and how can I get it to stop doing it?

This is inconsistent and sometimes no problems, but sometimes yes a problem (about 50% maybe).

I saw a message that said "you must stop the worker process." I can't be running to my server and stopping a process every time a user wants to reupload or delete a file. So what is the solution?

This is a windows 2012 R2 web server.
Please help.

thanks
LVL 2
Starr DuskkASP.NET VB.NET DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan McFaddenSystems EngineerCommented:
I would recommend creating and using a custom account for the AppPool instead of using the default identity options.

If you are uncomfortable with using a domain based service account, use a local account instead.  Insert the account into the IIS_IURS group and test.

As for the worker process, that is the w3wp.exe which is the AppPool.  Its probably holding a lock on the file because of the delete request, subsequent access denied error and probably the fact that there is no error handling being done in the VBScript.

Dan
0
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
Sorry my bad.

I have two websites. One was setup for AppPool as indicated in my message. The other one I setup the anonymous user as the IUSR, and permission on folder for that. Then tried the IIS_IUSRS because someone said asp classic required that and it still didn't work. So the other website, I setup using AppPool so I could test both ways.

But I also have an asp.net website with same problems.

I did have error handling in the vbscript, but handling the error and displaying a message to the screen is not fixing the problem. I need a fix.

The Worker Process error only occurs when I try to delete directly from the server.

Thanks for your recommendations on using another user, but I've done that, am doing that, same problem. I was just trying to explain the problem briefly without all the details as to what all I've tried.

I need to know how to fix this and get it to release the lock so I can delete it.

thanks!
0
Dan McFaddenSystems EngineerCommented:
Do you have ASP.NET Impersonation enabled for the .NET app?

Reference:  https://msdn.microsoft.com/en-us/library/xh507fc5(v=vs.100).aspx

Also, can you post the full error message?

Dan
0
Dan McFaddenSystems EngineerCommented:
Also, in your ASP script, are you calling the "Close" method when done with the files?  Not disposing of open file connections can cause the process supporting the execution of the ASP script to hold a file lock.

For example, I have always used a function in ASP/VBScript to control access to file objects.  The functions accept a path to a file and then instantiate the fso, perform the requested action, call the close method and/or set the created object(s) to Nothing.

Dan
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.