Login failed for user'IIS APPPOOL\xxxx'
1. After the phenomenon is
published to iis, the following prompt appears on the website 异常详细信息: System.Data.SqlClient.SqlException: 用户
‘IIS APPPOOL\IdealTest’
登录失败。
2. Analysis of the reason
1. Check the database connection string in the project web.config file:Integrated Security=True;
The integrated security=True is set here, and the integrated security mode is true. In this case, the website program pool account is required to be consistent with the account used by sqlserver to run.
2. Open iis, view the application pool, use the integrated authentication mode, its identification is ApplicationPoolIdentity, resulting in an error connecting to the database
Three, the solution
1. Modify the connection string of SQL Server and log in with the database account password
server=localhost;uid=sa;pwd=xxxx;database=master;
2. IIS Manager => Application Pool => Program Pool corresponding to the website => Advanced Settings-"Identification -" Change the ApplicationPoolIdentity under the process model to localSystem
Use SqlServer authentication method
<add name="CodeFirstModelEntities" connectionString="metadata=res://*/CodeFirstDB.csdl|res://*/CodeFirstDB.ssdl|res://*/CodeFirstDB.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=CodeFirstModel;uid=sa;pwd=123456;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />