[英]Connecting to SQL database works when ASP application is hosted in IIS Exress but doesn't work when hosted in Local IIS
In my MVC API web service, I created a simple SQL connection object with a connection string in a Get method.在我的 MVC API Web 服务中,我使用 Get 方法中的连接字符串创建了一个简单的 SQL 连接对象。 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.我还创建了一个 Ado.net 数据模型(具有相同的连接字符串)并编写了一个 LINQ 语句以使用相同的 Get 方法从数据库中获取一行。
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.当 MVC 应用程序设置为 IIS Express 时,ado.net connection.open() 命令和实体框架 LINQ 语句都可以工作,并从数据库中检索数据。
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:但是,当我更改为本地 IIS(我需要它是本地 IIS)时,使用两种方式连接到数据库都失败,这是以任何一种方式出现的错误:
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.当您在 SQL Server 连接中使用集成安全性与本地 IIS 一起运行时,到您的 SQL Server 实例的连接是在运行 IIS 应用程序池的帐户上下文下进行的。 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.使用 IIS Express 时情况并非如此,因为 IIS Express 在您帐户的上下文中运行,我假设您的帐户确实具有数据库权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.