为什么在ASP.Net身份删除不支持 [英] Why's Delete not supported in ASP.Net Identity

查看:177
本文介绍了为什么在ASP.Net身份删除不支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是用最近与Visual Studio 2013年RTM'd新AUTH功能修修补补

I was tinkering with the new auth features that recently RTM'd with Visual Studio 2013.

虽然实现自定义UserStore,我有一个看的UserStore反编译来源附带在框中, Microsoft.AspNet.Identity.EntityFramework.UserStore<&TUSER GT; 。我注意到,不支持删除用户的方法:

While implementing a custom UserStore, I was having a look at the decompiled sources for the UserStore that ships in the box, Microsoft.AspNet.Identity.EntityFramework.UserStore<TUser>. I noticed that the method for deleting a user was not supported:

  public class UserStore<TUser> : IUserLoginStore<TUser>, IUserClaimStore<TUser>, IUserRoleStore<TUser>, IUserPasswordStore<TUser>, IUserSecurityStampStore<TUser>, IUserStore<TUser>, IDisposable where TUser : IdentityUser
  {
       // other stuff omitted

    public virtual Task DeleteAsync(TUser user)
    {
      throw new NotSupportedException();
    }
  }

这很奇怪,不是吗?为什么删除用户不支持?

That's strange isn't it? Why is deleting a user not supported?

我承认我不记得,我已经写了硬删除用户记录的生产系统,但我不明白为什么不支持此功能。

I admit I can't remember a production system that I've written that hard deleted user records, but I don't understand why this functionality is not supported.

是否有技术原因或者是仅仅是因为微软认为,删除用户记录是坏和叶子它作为一个练习开发商要覆盖的方法?

Is there a technical reason or is it simply because Microsoft feels that deleting user records is "bad" and leaves it as an exercise for the developer to override the method?

在试图了解一下ASP.NET团队就在想,我搜索了的框架用法DeleteAsync(TUSER用户)。在框架中似乎没有任何调用它。因此,似乎他们可以完全离开成员关的 IUserStore&LT; TUSER方式&gt; 接口

In an attempt to understand what the ASP.NET team was thinking, I searched for framework usages of DeleteAsync(TUser user). Nothing in the framework seems to invoke it. So, it seems that they could have completely left the member off of the IUserStore<TUser> interface.

我在这一点上的结论是,它的存在来实现,如果你想和你想怎么,它仅会被你的应用程序code或将来的用户管理库调用。

My conclusion at this point is that it's there to implement if you want and how you want and that it will only ever be invoked by your application code or future user management libraries.

推荐答案

删除用户帐号

在1.0,如果你要删除一个用户,你可以不通过的UserManager做到这一点。他们现在已经有2.0固定它:

In 1.0, if you had to delete a User, you could not do it through the UserManager. They have now fixed it with 2.0:

var result = await UserManager.DeleteAsync(user);

请参阅http://blogs.msdn.com/b/webdev/archive/2014/03/20/test-announcing-rtm-of-asp-net-identity-2-0-0.aspx

这篇关于为什么在ASP.Net身份删除不支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆