当我在Thinktecture IdManager中编辑用户时,我可以更改他们的名称、年龄和其他“自定义”属性,但是当我试图更改他们的电子邮件地址或密码时,我会调用一次自定义成员资格重新引导存储库更新方法来保存更改,然后再调用一次以恢复更改。
由于某种原因,AutoFac容器中间件两次调用控制器。
只有一个HTTP来自IdMgr应用程序,因此它不是客户端问题。
第一个堆栈跟踪是..。
Gaist.Authentication.dll!Gaist.Authentication.MR.MembershipRebootRepository.Update(Gaist.Authentication.Mongo.Models.CustomUser item) Line 71 C#
[External Code]
IdentityManager.MembershipReboot.dll!IdentityManager.MembershipReboot.MembershipRebootIdentityManagerService<Gaist.Authentication.Mongo.Models.CustomUser,Gaist.Authentication.Mongo.Models.CustomGroup>.SetPassword(Gaist.Authentication.Mongo.Models.CustomUser account, string password) Line 235 C#
IdentityManager.dll!IdentityManager.ExpressionPropertyMetadata<Gaist.Authentication.Mongo.Models.CustomUser,string>.Set(object instance, string value) Line 87 C#
IdentityManager.dll!IdentityManager.PropertyMetadataExtensions.TrySet(IdentityManager.PropertyMetadata property, object instance, string value, out IdentityManager.IdentityManagerResult result) Line 137 C#
IdentityManager.dll!IdentityManager.PropertyMetadataExtensions.TrySet(System.Collections.Generic.IEnumerable<IdentityManager.PropertyMetadata> properties, object instance, string type, string value, out IdentityManager.IdentityManagerResult result) Line 123 C#
IdentityManager.MembershipReboot.dll!IdentityManager.MembershipReboot.MembershipRebootIdentityManagerService<Gaist.Authentication.Mongo.Models.CustomUser,Gaist.Authentication.Mongo.Models.CustomGroup>.SetUserProperty(System.Collections.Generic.IEnumerable<IdentityManager.PropertyMetadata> propsMeta, Gaist.Authentication.Mongo.Models.CustomUser user, string type, string value) Line 590 C#
IdentityManager.MembershipReboot.dll!IdentityManager.MembershipReboot.MembershipRebootIdentityManagerService<Gaist.Authentication.Mongo.Models.CustomUser,Gaist.Authentication.Mongo.Models.CustomGroup>.SetUserPropertyAsync(string subject, string type, string value) Line 503 C#
IdentityManager.dll!IdentityManager.Api.Models.Controllers.UserController.SetPropertyAsync(string subject, string type) Line 205 C#
[External Code]
IdentityManager.dll!IdentityManager.Configuration.Hosting.KatanaDependencyResolver.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Line 35 C#
[External Code]
IdentityManager.dll!IdentityManager.Configuration.Hosting.AutofacContainerMiddleware.Invoke(System.Collections.Generic.IDictionary<string,object> env) Line 51 C#
[External Code]
IdentityManager.dll!Owin.IdentityManagerAppBuilderExtensions.UseIdentityManager(Microsoft.Owin.IOwinContext ctx, System.Func<System.Threading.Tasks.Task> next) Line 55 C#
[Resuming Async Method]
[External Code]第二个堆栈跟踪是..。
Gaist.Authentication.dll!Gaist.Authentication.MR.MembershipRebootRepository.Update(Gaist.Authentication.Mongo.Models.CustomUser item) Line 71 C#
[External Code]
IdentityManager.MembershipReboot.dll!IdentityManager.MembershipReboot.MembershipRebootIdentityManagerService<Gaist.Authentication.Mongo.Models.CustomUser,Gaist.Authentication.Mongo.Models.CustomGroup>.SetUserPropertyAsync(string subject, string type, string value) Line 511 C#
IdentityManager.dll!IdentityManager.Api.Models.Controllers.UserController.SetPropertyAsync(string subject, string type) Line 205 C#
[External Code]
IdentityManager.dll!IdentityManager.Configuration.Hosting.KatanaDependencyResolver.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Line 35 C#
[External Code]
IdentityManager.dll!IdentityManager.Configuration.Hosting.AutofacContainerMiddleware.Invoke(System.Collections.Generic.IDictionary<string,object> env) Line 51 C#
[External Code]
IdentityManager.dll!Owin.IdentityManagerAppBuilderExtensions.UseIdentityManager(Microsoft.Owin.IOwinContext ctx, System.Func<System.Threading.Tasks.Task> next) Line 55 C#
[Resuming Async Method]
[External Code] 发布于 2015-08-14 10:53:06
之所以发生这种情况,是因为出柜的MembershipRebootIdentityManagerService实现假设存储库将基于实体框架,并且调用两次保存将在EF上下文的同一个实例上工作,因此也就是在同一个实体上工作。
我的回购实现没有那样工作,所以它加载一个未保存的实体,然后覆盖设置。
我不得不对我的存储库进行编码,以保存在回购过程中被编辑的实体。
https://stackoverflow.com/questions/30485834
复制相似问题