1

我已经上传了我的数据库备份,它工作正常。但由于我已经从 ASP.NET 配置创建了一个新用户,因此我已经将用户信息保存在 ASPNETDB 中。

我已经从 MVS 发布了我的数据库并在 M SQL Server Management Studio 2008 中打开它以创建备份,但我没有在其中找到 ASPNETDB。

我的问题是:

  1. 当我上传我的数据库时,这个数据库不会自动上传吗?因为当我发布我的网站时它没有出现。

  2. 如果没有,我如何上传 ASPNETDB 以便我可以登录到我的网站,因为我正在使用对该用户的授权?

4

2 回答 2

0

我想您正在使用 Membership API。

如果您在装有 SQL Server Express Edition 的计算机上使用 ASP.NET,则在创建第一个用户时会自动为您创建 Membership API 基础数据存储所需的数据。此功能是通过 SqlMembershipProvider 提供的。SqlMembershipProvider 会自动在网站的 App_Data 特殊目录中创建一个名为 ASPNETDB.MDB 的新数据库。该数据库实现了完整的模式,这是存储和管理用户信息、角色信息、用户角色分配等所必需的。

你可以很容易地检查它。在您的 web.config 中,您应该看到如下内容:

<connectionStrings>
    <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
      providerName="System.Data.SqlClient" />
 </connectionStrings>

所以这个数据库应该和你的网站一起上传。

如果您想在自己的数据库中创建 aspnetdb 或必要的表(这是一个很好的实践),请考虑本教程。

可能你也会对这里的类似讨论感兴趣。此外,如果您仍想在 SQL Server Management Studio 中获取此 .mdf 数据库,您可以在此处了解如何附加数据库。

于 2011-07-12T13:12:38.007 回答
0

Ok im gonna make a few assumptions here and explain them because this could be many things:

Assumption 1 (connection string issue). the user credentials for a database running on your local sql server are likely to be valid on the server on which you deploy to (seems to be the way of the world) try connecting to the remote database using the credentials in the remote "published" copy of the websites configuration file. (connection string)

Assumption 2 (publish settings not correct). when you use the "publish" option from within visual studio you only deploy the website to my knowledge but some say you can configure it to deploy the database as well.

I would suggest making a change (eg add a table to the aspnet database) on your dev machine then using publish to see if that new table appears on the remote server, if it doesn't go to the server explorer in visual studio and run the wizard by right clicking on your database and clicking on "publish to provider" i tend to push the entire db to a script file then manually run that on the remote database (seems the cleanest option).

Assumption 3 (does the database even exist on the server). I could be wrong here but from what you're saying it sounds like you published the application and not the database to the server ... that results in some nice yellow server errors.

Check that the database exists if not ... do as suggested in asumption 2 and push the database manually.

于 2011-07-12T13:18:22.617 回答