gpt4 book ai didi

asp.net - SQL部署后无法连接

转载 作者:行者123 更新时间:2023-12-02 23:56:03 31 4
gpt4 key购买 nike

我最近在 IIS (LocalDB) 上部署了我的网站。但每当我尝试运行该网站时,SQL 都无法连接。我现在已经浏览了数百篇帖子/文章,但无法解决它。

错误

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details. )

Windows 应用程序事件日志

Windows API call SHGetKnownFolderPath returned error code: 5. Windows system error message is: Access is denied. Reported at line: 422.

第二个日志 -

Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user.

我的连接字符串(都尝试过)-

<appSettings>
<add key="ConnectionString" value="Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=test;Integrated Security=True" />
<!--<add key="ConnectionString" value="data source=(LocalDB)\MSSQLLocalDB;UID=SOME_USERNAME;PWD=SOME_PASSWORD;initial catalog=test;connection timeout=30"/>-->
</appSettings>

我尝试编辑 applicationHost.config
Load User Profile对我来说已经是真的

我的ApplicationHost.config文件

 <applicationPools>

<add name="Classic .NET AppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" />
<add name=".NET v2.0 Classic" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" />
<add name=".NET v2.0" managedRuntimeVersion="v2.0" />
<add name=".NET v4.5 Classic" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" />
<add name=".NET v4.5" managedRuntimeVersion="v4.0" />
<add name="ASP.NET v4.0" managedRuntimeVersion="v4.0">

<add name="DefaultAppPool" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated">
<processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
</add>
</applicationPools>

我的 IIS 管理器 - enter image description here

默认应用程序池 -

enter image description here

我的网络应用配置 -
enter image description here

应用程序池权限
enter image description here

编辑-

使用添加了 IIS 应用程序池

icacls c:\inetpub\wwwroot /grant "IIS APPPOOL\DefaultAppPool":(OI)(CI)(RX)

仍然无法连接。

感谢任何帮助。

我在 Windows 10 上使用 Visual Studio 2015 和 SQL Server 2016。

最佳答案

也有同样的问题。不过,我并没有尝试你所做的所有事情。我做了以下事情:

  1. IIS 管理器
  2. 应用程序池
  3. 找到您的应用所属的池(对我来说是 .NET v4.5)
  4. 右键单击 -> 高级设置
  5. 向下滚动至身份
  6. 从任何内容(对我来说是 ApplicationPoolIdentity,与您相同)更改为 LocalSystem

关于asp.net - SQL部署后无法连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38441894/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com