Can't connect to SQL Server from IIS application

-5

Inner exception:

Unable to open database. Connection string: 'Integrated Security=SSPI;Pooling=false;Data Source=.\SQLEXPRESS;Initial Catalog=dbName;';

Error: 'System.Data.SqlClient.SqlException (0x80131904): Cannot open database "dbName" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\IUSR'.

at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry) at System.Data.SqlClient.SqlConnection.Open() at DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateDataBase(SqlConnection conn) ClientConnectionId:0b0d0125-ab23-474c-9360-c2556cb81904 Error Number:4060,State:1,Class:11'

I can debug the application and connects without problems, but as soon as I publish it to IIS on my local one and only windows 10 PC with 2016 sql express it can't connect.

Protocols for SQL Server are Name Pipes Enabled, Shared Memory Enabled,TCP/IP Enabled

The database has no password so neither the connection string. I created a login and user for IIS APPPOOL\AppPoolName

The connection string in the application in Visual Studio is:

<add name="ConnectionString" 
     connectionString="Integrated Security=SSPI;Pooling=false;Data Source=.\SQLEXPRESS;Initial Catalog=dbName" />
sql
sql-server
asked on Stack Overflow Jan 18, 2019 by JRR • edited Jan 18, 2019 by marc_s

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0