2

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:

  1. Login failed for user 'IIS APPPOOL\ASP.NET v4.0'

  2. https://www.youtube.com/watch?v=18-zatWd68s

  3. Added permissions to both folder and .mdf file to 'ASP.NET v4.0'

  4. https://blogs.msdn.microsoft.com/sqlexpress/2011/12/08/using-localdb-with-full-iis-part-2-instance-ownership/

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.

Community
  • 1
  • 1
Aj Grandeza
  • 75
  • 1
  • 8
  • You've already seen https://blogs.msdn.microsoft.com/sqlexpress/2011/12/08/using-localdb-with-full-iis-part-2-instance-ownership/ It says you basically have 3 options, run IIS as your ID (bad idea), run localdb as a shared instance, or use SQL Express - the last is probably the best advice. – Liesel Jan 25 '16 at 04:58
  • You're right, I passed that info after working for long hours, wasn't thinking clearly at that time.. I used sqlexpress instead of localdb.. – Aj Grandeza Jan 27 '16 at 08:16

1 Answers1

0

You've already seen https://blogs.msdn.microsoft.com/sqlexpress/2011/12/08/using-localdb-with-full-iis-part-2-instance-ownership/

It says you basically have 3 options,

  • run IIS as your ID (bad idea),
  • run localdb as a shared instance, or
  • use SQL Express

The latter is probably the best advice.

Liesel
  • 2,929
  • 2
  • 12
  • 18
  • I tried 2nd approach , first I do this sqllocaldb share v11.0 IIS_DB I change my data source to (LocalDb)\v11.0.\IIS_DB it gives network instance error. – Ghazanfar Khan Jan 31 '16 at 11:52