Asp.net 会员资格
如果我想做一个管理功能,比如删除 asp.net mvc 示例附带的 asp.net 会员资格中的用户。
我尝试查看表格,发现有多个表格添加了行。 我想一定有一个更简单的方法。
If I want to do an admin function like delete a user on the asp.net membership stuff that ships with the asp.net mvc sample.
I tried looking through the tables and realized that there was multiple tables that had rows added. I assume there must be a simpler way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在您的会员资格提供程序中,有一个方法:
如果这是标准的 asp.net 会员资格提供程序,则该方法运行一个存储过程,从数据库中清除用户。
这里还有一些例子:
https://web. archive.org/web/20210304121422/https://www.4guysfromrolla.com/articles/091207-1.aspx
In your Membership provider there is a method:
If this is the standard asp.net membership provider that method runs a stored proc that cleans the user from your DB.
Here is some more examples:
https://web.archive.org/web/20210304121422/https://www.4guysfromrolla.com/articles/091207-1.aspx
使用会员 API。
要删除用户,请使用 Membership.DeleteUser 方法
Use the Membership API's.
To delete a user, use the Membership.DeleteUser method
不要直接从数据库中删除,请通过会员资格提供商并调用 会员资格.DeleteUser 方法。
Don't delete direct from the database, go through the membership provider and call the Membership.DeleteUser method.
成员资格提供程序 基类 具有以下方法你需要。 例如,要删除用户,您可以使用 DeleteUser 方法。 您不需要做的是直接访问 SQL 数据库
The Membership Provider base class has the methods you need. For example to delete a user you use the DeleteUser method. What you do NOT do is directly access the SQL database
您还可以使用 ASP.NET 配置工具。
http://msdn.microsoft.com/en-us/library/ms998347。 aspx - 步骤 3 显示如何添加用户。 同样的原则也适用于删除它们。 您还可以将它们标记为非活动状态,而不是删除它们。 我通常将它们标记为非活动状态以保留我的数据库关系。
You can also use the ASP.NET Configuration Tool.
http://msdn.microsoft.com/en-us/library/ms998347.aspx - Step 3 shows how to add users. The same principle applies for deleting them. You can also mark them as inactive instead of deleting them. I usually mark them as inactive to preserve my database relationships.