0

I have an ASP.net web application (C#) hosted by IIS on my server that connects with an Access database. It's important that I can have the database open in Access and still use the website at the same time.

I get the "Could not use file; file already in use" error whenever I try this. I've done a ton of research on this topic but nothing really seems to work.

I have modify permissions added for IUSR, NETWORK SERVICE and IIS_IUSRS for the folder containing the database. None of this seems to work.

Oddly enough, I tried hosting the website from my local machine and the solution above solved the issue, but it does not work when hosting the website from my server.

My website also chokes up when trying to do an INSERT statement even when the database is closed. I get the error "operation must use an updateable query"

Any thoughts? Thanks.

8
  • You describe 2 apparently distinct questions. I can probably help you with the first. would need to see code to help with second Commented Nov 29, 2017 at 17:45
  • I'm not as concerned about the second one, I'm sure I can figure that one out. I just didn't know if that was relevant to the first problem. Commented Nov 29, 2017 at 17:47
  • "I tried hosting the website from my local machine" can you be specific about you did? or what would be different then what you tried on the server? Commented Nov 29, 2017 at 18:27
  • I first published the website to a folder on my desktop and put a copy of the database in another folder on my desktop. I set all the permissions mentioned above for the database folder. I then used IIS to host the website as an application within my Default Web Site Everything seems to work. I tried to replicate this process with the server (website published in a folder on the server, database in a folder within the website root folder, permissions added). This configuration gives the error. I'm wondering if there's settings within IIS that's different between my computer and the server. Commented Nov 29, 2017 at 18:36
  • The Key is the App Pool that was configured for the application on IIS. That was what I was hoping to get information about. That is what you have to enable the permissions for on the respective folder. If you don't know exactly what I am referring to then I can try and provide the steps in an answer Commented Nov 29, 2017 at 19:06

2 Answers 2

1

In regards to:

but it does not work when hosting the website from my server

I am not sure about the rest of your configuration, but this may shed some light onto why you are getting different behaviors on different systems: You should enable the same permissions (for the Database folder) for the Identity under which the Application Pool you have configured for your Application in IIS.

  1. Open your Server's IIS Management Console
  2. See what the Application Pool is for your App right click on the Application node: 'manage Application' >> 'Advanced Settings' >> Application Pool

  3. Open Application Pools View: Find the App Pool

  4. right Click the App Pool >> Advanced Settings
  5. Look for the Identity value
  6. That is the Identity you should replicate the permissions for as you did on your local machine's folders

P.S.: It is usually recommended that you configure/create a dedicated App pool for each of your applications.

Hope this helps resolve your issue.

Sign up to request clarification or add additional context in comments.

5 Comments

Feels like I'm getting a lot closer. I was able to add permissions to "DefaultAppPool" but it still doesn't seem to make a difference. I used this article as a reference based on what you were saying: learn.microsoft.com/en-us/iis/manage/configuring-security/…
Yes... that article is a good resource. If I were you I would create a dedicated app pool and run it under the NetworkService Identity. ApplicationPoolIdentity has been troublesome ever since its introduction.
I have not red this thoroughly but it seems to have good relevant info: stackoverflow.com/questions/5437723/…
Thanks for all your help, I really appreciate it. I'm still plugging through this, hopefully arriving to a solution soon.
You are welcome! this stuff is tricky as it falls outside the usual realm of coding but it does become more intuitive over time. If you found this helpful a simple up vote would be graciously welcomed.
0

I am answering six years after the question was asked, much too late to help the person originally seeking help, but perhaps not too late to help anyone else who stumbles on this page while researching this type of issue. The exact same thing happened to me, and one solution was to give full control of the folder in which the Access database sits to "Users" as well as "IIS_IUSRS". That seems to cover the ASP app pool identity without you even needing to figure out what it is. This solves both the file-in-use and refusal to update issues.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.