简体   繁体   English

ASP.NET在发布到IIS后失去与SQL Server Express的连接

[英]ASP.NET losing connection to SQL Server Express after being published to IIS

I have an ASP.NET application that gets data from a SQL Server Express on the same computer. 我有一个ASP.NET应用程序,它从同一台计算机上的SQL Server Express获取数据。 When I run the ASP.NET project from Visual Studio, the project can reach the database just fine. 当我从Visual Studio运行ASP.NET项目时,项目可以很好地到达数据库。 However, when published to IIS, the project loses the connection. 但是,在发布到IIS时,项目会丢失连接。 Here is my connection string located in Web.config : 这是我在Web.config连接字符串:

<connectionStrings>
    <add name="conString" 
         providerName="System.Data.SqlClient" 
         connectionString="Server = DESKTOP-EVAN\SERVER;Database=master;User ID=sa;Password=12345;" />
</connectionStrings>

The project can be reached on the published IIS, however no data is there and no error messages show. 可以在已发布的IIS上访问该项目,但是没有数据,也没有显示错误消息。

I've added the application pool and NT Authority to the SQL login but still no luck connection to the database. 我已经将应用程序池和NT Authority到SQL登录中,但仍然没有运气连接到数据库。

Does anyone have any experience with this? 有人对这个有经验么? How can I get my published ASP.NET project to connect to my SQL Server Express? 如何让我发布的ASP.NET项目连接到我的SQL Server Express?

您是否尝试过删除服务器的空间,如下所示:

 Server=DESKTOP-EVAN\SERVER

Did you install SQL Server Express on that machine where IIS is running, or on a machine that can be reached from the IIS machine? 您是在运行IIS的计算机上安装 SQL Server Express,还是在可以从IIS计算机访问的计算机上安装 SQL Server Express?

Also : did you explicitly define a separate instance name for your SQL Server Express when installing? 另外 :您在安装时是否为SQL Server Express明确定义了一个单独的实例名称

By default, the instance name would be SQLEXPRESS - but you seem to refer to DESKTOP-EVAN\\SERVER - so SERVER would be your instance name - is that the case?? 默认情况下,实例名称将是SQLEXPRESS - 但您似乎引用DESKTOP-EVAN\\SERVER - 所以SERVER将是您的实例名称 - 就是这种情况?

If not : can you try DESKTOP-EVAN\\SQLEXPRESS as the server/instance name instead? 如果不是 :您可以尝试使用DESKTOP-EVAN\\SQLEXPRESS作为服务器/实例名称吗?

<connectionStrings>
    <add name="conString" 
         connectionString="Server=DESKTOP-EVAN\SQLEXPRESS;Database=master;User ID=sa;Password=12345;" 
         providerName="System.Data.SqlClient" />
</connectionStrings>

You muss allow user for iis in security. 你在安全方面允许用户使用iis。 Here is oné video: https://youtu.be/rmVtxLKmkDU 这是oné视频: https ://youtu.be/rmVtxLKmkDU

I hope thats help you. 我希望这能帮到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM