我已經在服務器上部署了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以查看您的應用程序運行。 –
如果您使用生產數據庫,該怎麼辦? –