I have a application running on our server (it works fine on my computer not that it matters). It is a windows server 2003, Sql Express 2008 r2 server.
Im using a attached DB for storing users (the asp.net supplied db).
I can login to the web application with no problem but when i try to create a user it just says invalid value for key 'attachdbfilename' with the yellow screen of death.
here you have the connection string in the web.config
<add name="ConnectionStringASPNETDB.MDF" connectionString="Data Source=localhost\SQLEXPRESS_2008;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
and the membership provider
<add name="daganteckning" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ConnectionStringASPNETDB.MDF"
enablePasswordRetrieval="false"
enablePasswordReset="false"
requiresQuestionAndAnswer="false"
applicationName="/"
requiresUniqueEmail="false"
passwordFormat="Hashed"
description="Stores and retrieves membership data from a Microsoft SQL Server database." />
My only guess is that there is some sort of directory/file security permission i must set but i have no idea what user iis/sql uses to access the database file.
Any one got a idea?
Edit: I tryed by replacing localhost\sqlexpress_2008 with .\sqlexpress_2008 and now i got
Unable to open the physical file "C:\Inetpub\wwwroot\MEDLEM_TEST\App_Data\ASPNETDB.MDF". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)". An attempt to attach an auto-named database for file C:\Inetpub\wwwroot\MEDLEM_TEST\App_Data\ASPNETDB.MDF failed. A database w开发者_开发技巧ith the same name exists, or specified file cannot be opened, or it is located on UNC share.
Check if your server's antivirus or any other process could be accessing the file.
You could also try recycling the application after making the change you listed.
Also if you use the Asp.Net Configuration tool it will attach to the mdf file and your application will create that error while you are connected through that.
After browsing around i found that i was not using the defined provider unless i stated that i wanted to use it by name.. so i solved it by adding <clear />
to the Providers tag and adding the attribute defaultProvider="daganteckning" to the membership tag.
<membership defaultProvider="daganteckning">
<providers>
<clear />
<add name="daganteckning" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ConnectionStringASPNETDB.MDF"
enablePasswordRetrieval="false"
enablePasswordReset="false"
requiresQuestionAndAnswer="false"
applicationName="/"
requiresUniqueEmail="false"
passwordFormat="Hashed"
description="Stores and retrieves membership data from a Microsoft SQL Server database." />
</providers>
....
精彩评论