gpt4 book ai didi

c# - 部署 ASP.NET MVC + LocalDB 应用程序时出现问题

转载 作者:行者123 更新时间:2023-12-02 04:42:41 25 4
gpt4 key购买 nike

我已经在服务器上部署了我的 ASP.NET MVC 5 应用程序,但它在使用 localdb 的每个页面上都崩溃了。

但是我复制了 .mdf 文件所在的 App_Data 文件夹。我什至在机器上安装了 SQL Server 2012 Express。

然而每次我都遇到同样的错误。

Le fichier spécifié est introuvable
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: Le fichier spécifié est introuvable

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[Win32Exception (0x80004005): Le fichier spécifié est introuvable]
[SqlException (0x80131904): 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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5352431

抱歉,尽管我将用户界面设置为美国英语,但它的一部分是法语。

web.config 文件如下所示:

<connectionStrings>
<add name="ConnectionString"
connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=C:\inetpub\wwwroot\MygLogWeb\App_Data\Database.mdf;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>

之前是这样的:

<add name="ConnectionString" 
connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True"
providerName="System.Data.SqlClient"/>

最佳答案

那是因为 LocalDb 不适用于生产用途。

参见文章:Creating an Entity Framework Data Model for an ASP.NET MVC Application

具体来说,文章中的这段文字:“通常 SQL Server Express 不用于生产 Web 应用程序。特别不建议将 LocalDB 用于 Web 应用程序的生产使用,因为它不是为与 IIS 一起工作而设计的。”

因此,更改您的 connectionString 值以使用真正的 sql server 数据库,您应该可以开始了!

关于c# - 部署 ASP.NET MVC + LocalDB 应用程序时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20476608/

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