【问题标题】:Publish web in MVC在 MVC 中发布网页
【发布时间】:2016-06-19 22:02:44
【问题描述】:

我有一个想要发布和上传的 MVC 项目

我要求服务器提供商上传我的数据库。 我的数据库是本地的

这里是这个的信息:

名称:vidiaweb_com_TourDbContext

数据库:vidiaweb_com_TourDbContext-20160613111028

这是我的连接字符串

<connectionStrings> <add name="vidiaweb_com_TourDbContext" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\vidiaweb_com_TourDbContext-20160613111028.mdf;Initial Catalog=vidiaweb_com_TourDbContext-20160613111028;Integrated Security=True;User Id=vidiaweb_com_TourDbContext;Password=password;" providerName="System.Data.SqlClient" /> </connectionStrings>

但是在每个页面中都有这样的模型例如

@model IEnumerable<vidiaweb_com.Models.Country>

,出现错误:

'Server Error in '/' Application.  
The system cannot find the file specified  
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: The system cannot find the file specified  

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): The system cannot find the file specified]  '

有人知道可能是什么问题吗?

【问题讨论】:

    标签: asp.net-mvc database localhost publish


    【解决方案1】:

    很明显,您的网络主机没有将数据库放在您网站的/App_Data/ 目录中,这就是您在|DataDirectory|\ 的连接字符串中指定的内容。它很可能附加到一个真实的 SQL Server 实例,在这种情况下,您无需指定目录。

    您需要从您的网络主机获取数据库的服务器详细信息。您的连接字符串很可能看起来像这样:

    SERVER=data.somewhere.com;DATABASE=vidiaweb_com_TourDbContext;UID=TheApplicationUserName;PWD=TheApplicationPassword;
    

    有关连接字符串的更多示例,请参阅ConnectionStrings.com

    【讨论】:

      猜你喜欢
      • 2013-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-01
      • 1970-01-01
      • 2011-03-02
      • 1970-01-01
      相关资源
      最近更新 更多