使用 OWIN/Katana 在 Azure 上的数据保护操作不成功 [英] The data protection operation was unsuccessful on Azure using OWIN / Katana

查看:11
本文介绍了使用 OWIN/Katana 在 Azure 上的数据保护操作不成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Azure 中运行的基于 OWIN/Katana 的 ASP.NET MVC 网站上实现密码重置.

I'm trying to implement password reset on an OWIN/Katana based ASP.NET MVC website running in Azure.

在本地运行时运行良好,但在生产中失败.

It works fine when run locally but fails in production.

我创建了一个 UserToken 提供者

I create a UserToken Provider

userManager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>(provider.Create("PasswordReset"))

但是当我尝试按如下方式生成令牌时

But when I attempt to generate the token as follows

var resetToken = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

我收到以下异常.

System.Security.Cryptography.CryptographicException:数据保护操作失败.这可能是由没有为当前线程的用户加载用户配置文件上下文,这可能是线程模拟时的情况.在 System.Security.Cryptography.ProtectedData.Protect(Byte[] userData, Byte[] optionalEntropy, DataProtectionScope 范围)在 System.Security.Cryptography.DpapiDataProtector.ProviderProtect(Byte[]用户数据)在 System.Security.Cryptography.DataProtector.Protect(Byte[] userData)在 Microsoft.Owin.Security.DataProtection.DpapiDataProtector.Protect(Byte[]用户数据)在 Microsoft.AspNet.Identity.Owin.DataProtectorTokenProvider 2.d__0.MoveNext()--- 从上一个抛出异常的位置开始的堆栈跟踪结束 ---在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task任务)在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task任务)在 Microsoft.AspNet.Identity.UserManager`2.d__e9.MoveNext()

System.Security.Cryptography.CryptographicException: The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating. at System.Security.Cryptography.ProtectedData.Protect(Byte[] userData, Byte[] optionalEntropy, DataProtectionScope scope) at System.Security.Cryptography.DpapiDataProtector.ProviderProtect(Byte[] userData) at System.Security.Cryptography.DataProtector.Protect(Byte[] userData) at Microsoft.Owin.Security.DataProtection.DpapiDataProtector.Protect(Byte[] userData) at Microsoft.AspNet.Identity.Owin.DataProtectorTokenProvider 2.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNet.Identity.UserManager`2.d__e9.MoveNext()

推荐答案

如果主机服务器是虚拟机,它可能正是错误消息所说的那样.检查您在 IIS 中的应用程序池是否真的将 Load User Profile 设置为 true,就像异常说的那样:

If the host server is a virtual machine it could be exactly what the error message says. Check if your Application Pool in IIS really has Load User Profile set to true like the exception says:

  • 在连接"窗格中,展开服务器名称,然后单击应用程序池".
  • 右键点击你的池
  • 高级设置

这篇关于使用 OWIN/Katana 在 Azure 上的数据保护操作不成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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