如何将具有 ASPNETDB.MDF 数据库的站点从开发服务器托管到生产服务器?
我使用 ASP.NET Personal Starter Kits 3.5 创建了我的网站。我只使用 Visual Studio 2008。 .使用其内置的 SQL Server (2005 Express) ...我在 App_Data
中的数据库是 ASPNETDB.MDF
...
我还创建了一些表.. ..在 ASPNETDB 中..
在我的本地 PC 中,该网站运行良好...
但是当我在生产服务器上发布我的网站时,它不起作用并显示以下错误
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
注释:您看到的当前错误页面可以替换为通过修改应用程序配置标记的“defaultRedirect”属性以指向自定义错误页面 URL,可以创建自定义错误页面。
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
我的托管提供商连接字符串..
<add name="ConnectionString" connectionString="Data Source=69.16.253.19;Initial Catalog=usa_data;Persist Security Info=True;User Id=user;Password=pass" providerName="System.Data.SqlClient"/>
我的托管提供商为我提供了连接到 SQL Server 2005 的连接字符串,但它不起作用...
我不明白为什么我的网站在我的环境中使用生产 SQL Server 2005 运行良好本地电脑,当我仅在本地电脑的 App_Data 中包含 ASPNETDB.MDF 文件时...如果我从本地电脑的 App_Data 中删除文件 ASPNETDB.MDF ...该网站将停止工作...
任何人都可以告诉他们如何解决此问题。 ..!!过去三四天以来我非常紧张
I have created my site using ASP.NET Personal Starter Kits 3.5. I use Visual Studio 2008 only . .with its built-in SQL Server (2005 Express) ... my database in App_Data
is ASPNETDB.MDF
...
I have created some of my tables also ....in ASPNETDB ..
In my local PC the site was running fine ...
But when I publish my site on production server it doesn't work and shows the following error
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
My hosting provider connection string ..
<add name="ConnectionString" connectionString="Data Source=69.16.253.19;Initial Catalog=usa_data;Persist Security Info=True;User Id=user;Password=pass" providerName="System.Data.SqlClient"/>
My hosting provider gave me the connection string to connect to the SQL Server 2005 but it doesn't work...
I don't understand why my site was running fine using the production SQL Server 2005 in my local PC when I include ASPNETDB.MDF file in App_Data in my local pc only ..if I remove file ASPNETDB.MDF from App_Data of my local pc ... the site stops working ...
Can anybody tell em how to fix this ... !! I am very tensed since last 3-4 days
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,APP_DATA 文件夹中的文件在生产中无法作为数据库进行访问。
您必须将整个数据库从 ASPNETDB.MDF 迁移到生产数据库服务器(由提供商提供)。
然后该网站就可以工作了。
另外,将配置更改为:以查看确切的错误!
如果移植不起作用,请查看确切的错误并将其发布在此处。
Firstly, the file in the APP_DATA folder is not accessible as a DB in production.
You will have to migrate the whole Database from the ASPNETDB.MDF to the Production Database server (given by provider.)
And then the site will work.
Also, change the config to : to see the exact error!!
If the porting doesn't work, see the exact error and post it here.
备份 ASPNETDB.MDF 文件并将其导入到您的主机中,然后将其放入您的配置文件中:
make a backup of your ASPNETDB.MDF file an import it into your hosting after put this on your config file: