7

I have set up my website to use ASP.NET Membership. it all works fine when trying to use it on my development machine but when I put it on the web server and try to log in, I get this error :

"Failed to update database "C:\INETPUB\WWWROOT\APP_DATA\ASPNETDB.MDF" because the database is read-only. "
Attilah
  • 17,632
  • 38
  • 139
  • 202
  • Is the file readonly? Does the asp user account have permissions to write to the directory the database is in? – Sam Holder Apr 01 '10 at 12:50

6 Answers6

11

thanks for the help. I just found a solution. in the App_Data ACL, I had two entries : Network Service and IIS_IUSRS. the Network Service account had full permissions but IIS_IUSRS group had only read access. so, I gave IIS_IUSRS full permissions as well and it worked !

thanks again.

Attilah
  • 17,632
  • 38
  • 139
  • 202
5

Don't forget to restart the IIS with "iisreset.exe" after altering the permissions

2

Check that file on the disk. Right click and go to properties.

If it is a read-only file, you will need to make it writeable.

Tom Tresansky
  • 19,364
  • 17
  • 93
  • 129
  • yes, the file is read-only.it inherits this behavior from its parent folder App_folder. funny thing is that when I try to unset the App_Data folder from read-only, it goes back to read-only. don't know what to do ... – Attilah Apr 01 '10 at 13:01
  • 1
    I had a similar problem didn't notice that TFS set it to read-only after a checkin. – Evan Anger Aug 21 '12 at 22:45
2

If the file is read-only and you can't seem to change it using the Properties window, you have to use a command prompt.

Refer to this Support article at Microsoft.

Greg Andora
  • 1,372
  • 2
  • 11
  • 17
1

I followed Attilah's answer and found: 1. Both IIS-ISUR, WebService had full pomission to the App_Data and the mdf. 2. But someone called "asp.net 4.0 pool" and "all users" did not, so I allowed them.

Then 3. I followed user1280392's answer to run "iisreset" but failed (but still run it pls).

Then I went to IIS manager and did this: 4. Clicked the server's name, clicked "restart" on the right. 5. Clicked the applications name, clicked "restart" on the right.

and it was ok.

cheny
  • 2,545
  • 1
  • 24
  • 30
1

The user account that the website is running under needs write permissions on the file.

It is also likely that the file is read-only as result of the transfer and needs to be set to be writeable.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • I gave full permission to the Network Service account. I'm using Windows 7 – Attilah Apr 01 '10 at 14:27
  • Can you post the connection string? – Oded Apr 01 '10 at 14:47
  • 1
    Hi Oded, thanks for the help. I just found a solution. in the App_Data ACL, I had two entries : Network Service and IIS_IUSRS. the Network Service account had full permissions but IIS_IUSRS group had only read access. so, I gave IIS_IUSRS full permissions as well and it worked ! – Attilah Apr 02 '10 at 17:28