When we use the integrated security in the database connection string, the application hosted in the IIS/IIS Express
will try to connect the database with the current login Windows account
. If the Visual Studio
and SQL Server
are on the same machine, the database connection string with integrated security will work fine Cause that both these two applications (Web application and the SQL server) are running under the same windows account. When the web application is hosted in IIS/IIS Express
and the database connection way is integrated security, the default credential is used to connect the database is the windows account which is running the IIS/IIS Express
.
I recommend that we could change the way to connect the SQL server in the database connection string, such as the SQL Authentication
.
Data Source=mysqlserver;User ID=sa;Password=123456;Connect
Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
Alternatively, to avoid using the current windows account of the webserver to connect the database, it is available to change the application pool identity to another domain account, the premise is that the Windows account should be able to log in to the SQL server.
For more details about the Application pool identity
.
https://docs.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities
Feel free to let me know if the problem persists.