In my MVC API web service, I created a simple SQL connection object with a connection string in a Get method. I also created an Ado.net Data Model (with the same connection string) and wrote a LINQ statement to get a row from the database in the same Get method.
When the MVC application is set to IIS Express, both the ado.net connection.open() command and the Entity Framework LINQ statement work and data is retrieved from the database.
However, when I change to Local IIS (I need it to be Local IIS), connecting to the database fails using both ways and this is the error that appears in either way:
When you're running with Local IIS using Integrated Security in your SQL Server connection, the connection to your SQL Server instance is being made under the context of the account the IIS App Pool is running as. You need to do one of the following:
This was not the case when using IIS Express because IIS Express runs under the context of YOUR account, which I'm assuming does have permissions to the database.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.