部署ASP.NET MVC +的LocalDB应用程序时的问题 [英] Issue when deploying an ASP.NET MVC + LocalDB application

查看:206
本文介绍了部署ASP.NET MVC +的LocalDB应用程序时的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经部署在服务器上我的ASP.NET MVC应用5,但它使用的LocalDB每一页上崩溃。

不过,我复制其中密度纤维板文件位于的App_Data 文件夹中。我甚至安装SQL Server的机器上2012前preSS。

不过我每次得到同样的错误。


  

乐fichierspécifiéEST introuvable结果
  说明:执行当前Web请求的执行过程中发生未处理的异常。请查看有关错误的详细信息的堆栈跟踪以及它起源于code。


  
  

异常详细信息:System.ComponentModel.Win32Exception:乐fichierspécifiéEST introuvable


  
  

源错误:


  
  

当前Web请求的执行过程中生成了未处理的异常。有关异常的来源和位置信息可以使用异常堆栈跟踪下面确定。


  
  

堆栈跟踪:


  
  

[Win32Exception(0X80004005):乐fichierspécifiéEST introuvable]结果
  [SQLEXCEPTION(0x80131904):在与SQL Server建立连接时出现与网络相关的或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server配置为允许远程连接。 (提供者:SQL网络接口,错误:52 - 无法找到本地数据库运行时安装验证SQL服务器前preSS已正确安装以及本地数据库运行时功能被启用。)结果
  System.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,布尔breakConnection,Action`1 wrapCloseInAction)5352431


对不起,它的一部分■在法国,尽管我的UI设置为美国英语。

的web.config 文件看起来是这样的:

 <&是connectionStrings GT;
   <添加名称=的ConnectionString
        的connectionString =数据Source=(LocalDb)\\v11.0;AttachDbFilename=C:\\inetpub\\wwwroot\\MygLogWeb\\App_Data\\Database.mdf;Integrated安全=真
        的providerName =System.Data.SqlClient的/>
< /&是connectionStrings GT;

和它像在此之前:

 <添加名称=的ConnectionString
     的connectionString =数据源=(的LocalDB)\\ V11.0; AttachDbFilename = | DataDirectory目录| \\ Database.mdf;集成安全性=真
     的providerName =System.Data.SqlClient的/>


解决方案

这是因为的LocalDB不适合用于生产。

请参阅文章:<一href=\"http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application\"相对=nofollow>一个ASP.NET MVC应用程序创建实体框架数据模型

具体而言,从文章这样的文字:通常情况下不使用SQL Server的防爆preSS生产Web应用程序的LocalDB尤其不建议使用Web应用程序的生产使用,因为它的目的不是与IIS工作。

因此​​,改变你的连接字符串值中使用真实的SQL Server数据库,你应该是好去!

I have deployed my ASP.NET MVC 5 application on a server but it crashes on every page using the localdb.

Yet I copied the App_Data folder where the .mdf file is located. And I even installed SQL Server 2012 Express on the machine.

Nevertheless every time I get the same error.

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

Sorry, a part of it s in french despite I set the ui to us-english.

The web.config file looks like this:

<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>

And it was like this before:

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

解决方案

That's because LocalDb is not intended for production use.

See article: Creating an Entity Framework Data Model for an ASP.NET MVC Application

Specifically, this text from the article: "Typically SQL Server Express is not used for production web applications. LocalDB in particular is not recommended for production use with a web application because it is not designed to work with IIS."

So change your connectionString value to use a real sql server database and you should be good to go!

这篇关于部署ASP.NET MVC +的LocalDB应用程序时的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆