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.

Brock
  • 45
  • 7
  • You describe 2 apparently distinct questions. I can probably help you with the first. would need to see code to help with second – DaniDev Nov 29 '17 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. – Brock Nov 29 '17 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? – DaniDev Nov 29 '17 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. – Brock Nov 29 '17 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 – DaniDev Nov 29 '17 at 19:06
  • I compared the Default App Pools advanced settings between my computer IIS and the server IIS. The only difference was that the server had "Load User Profile" as false. I tried switching that to true, but it didn't change the issue. Other than that, they are identical to each other. – Brock Nov 29 '17 at 19:11
  • It is the identity under which the AppPool is using that you have to enable the respective permissions for on the folders. Specifically, they have to have write permissions on the Database file folder, etc. It is also advisable that you create dedicated app pool for your application. – DaniDev Nov 29 '17 at 19:19
  • I have in my web config. And it's my (limited) understanding that the identity would be IUSR in that case, which I have given permissions to. – Brock Nov 29 '17 at 19:29

1 Answers1

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.

DaniDev
  • 2,471
  • 2
  • 22
  • 29
  • 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: https://learn.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities – Brock Nov 29 '17 at 20:29
  • 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. – DaniDev Nov 29 '17 at 20:42
  • 1
    I have not red this thoroughly but it seems to have good relevant info: https://stackoverflow.com/questions/5437723/iis-apppoolidentity-and-file-system-write-access-permissions – DaniDev Nov 29 '17 at 20:45
  • Thanks for all your help, I really appreciate it. I'm still plugging through this, hopefully arriving to a solution soon. – Brock Nov 30 '17 at 16:34
  • 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. – DaniDev Nov 30 '17 at 17:25