I deployed a asp.net web api on my local IIS (7.0) and I can't get through in accessing the database.
When the identity (under process model) is set to LocalSystem
, API will return this exception:
Invalid object name 'dbo.tablename'
If I set the identity to ApplicationPoolIdentity
, the API will return this exception:
Cannot open database "dbname" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\ASP.NET v4.0'.
Solutions tried:
Added permissions to both folder and .mdf file to 'ASP.NET v4.0'
Other relevant information:
connection string (in web.config
)
<add name="DbContext"
connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=[dbname];Trusted_Connection=Yes;"
providerName="System.Data.SqlClient" />
I also tried running the application using Visual Studio using IIS Express, it worked fine.