我已经在服务器上部署了ASP.NET MVC 5应用程序,但它在每个使用localdb的页面上都崩溃了。部署ASP.NET MVC + 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
对不起,尽管我将ui设置为英文,但其中的一部分仍然以法语显示。
的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有什么好处呢? – Serge
快速发展。测试。很像Visual Studio可以根据需要启动一个新的Web服务器,而不是强迫您首先设置IIS以查看您的应用程序运行。 –
如果您使用生产数据库,该怎么办? –