ASP.NET 配置文件删除

发布于 2024-08-29 19:12:55 字数 424 浏览 1 评论 0原文

我们使用 ASP.NET 配置文件子系统将信息的键值对与用户相关联。

我正在实现删除用户的功能。

我一直在使用 ProfileManager.DeleteProfile(string userName) 方法,但我注意到这会在我们用来存储 aspnetdb 数据库的 aspnet_Users 表中留下一行个人资料信息。

显然,我可以直接操作数据库,但我不愿意这样做。

确保从 aspnetdb 中删除与用户相关的所有信息的最佳方法是什么?

PS:有一个诱人的 Membership.DeleteUser(string userName, bool deleteEverything) 方法,但这会返回数据库连接错误。 web.config 问题?

We use the ASP.NET profile subsystem to associate key-value pairs of information with users.

I am implementing functionality for the deletion of users.

I have been using the ProfileManager.DeleteProfile(string userName) method, but I have noticed that this leaves a row in the aspnet_Users table in the aspnetdb database we use to store the profile information.

Clearly, I could manipulate the database directly, but I am reluctant to do so.

What is the best way to ensure all information assocaited with a user is deleted from the aspnetdb?

PS: there is a tantalising Membership.DeleteUser(string userName, bool deleteEverything) method, but this returns a database connection error. A web.config issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Bonjour°[大白 2024-09-05 19:12:55

将成员资格部分添加到 web.config,链接到包含有效凭据的连接字符串(此处:“SqlServices”):

   <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="20">
      <providers>
        <remove name="AspNetSqlProvider" />
        <add name="SqlProvider"
          type="System.Web.Security.SqlMembershipProvider"
          connectionStringName="SqlServices"
          enablePasswordRetrieval="false"
          enablePasswordReset="true"
          requiresQuestionAndAnswer="true"
          passwordFormat="Hashed"
          applicationName="/" />
      </providers>
    </membership>

确保 aspnetdb 数据库中的 aspnet_SchemaVersions 表包含行:

membership 1 true

然后您可以使用成员资格 api (Membership.DeleteUser)。

Add a membership section to web.config, linked to a connection string containing valid credentials (here: "SqlServices"):

   <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="20">
      <providers>
        <remove name="AspNetSqlProvider" />
        <add name="SqlProvider"
          type="System.Web.Security.SqlMembershipProvider"
          connectionStringName="SqlServices"
          enablePasswordRetrieval="false"
          enablePasswordReset="true"
          requiresQuestionAndAnswer="true"
          passwordFormat="Hashed"
          applicationName="/" />
      </providers>
    </membership>

Ensure the aspnet_SchemaVersions table in the aspnetdb database contains the row:

membership 1 true

You may then use the membership api (Membership.DeleteUser).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文