在 MVC 中发布网页

Publish web in MVC

我有一个 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]  '

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

显然,您的虚拟主机并没有将数据库放在您网站的 /App_Data/ 目录中,这正是您在 |DataDirectory|\ 的连接字符串中指定的目录。它很可能附加到一个真实的 SQL 服务器实例,在这种情况下,您不需要指定目录。

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

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

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