1

大家好,我使用 VS 2012 开发了一个 WebForms 应用程序。我已经在 Azure 上发布了它。之后我集成了 ACS(我已将 URL 设置为我已经发布的应用程序)我再次发布了应用程序,但它不起作用。在我自己注册后(例如使用 Yahoo 或 LiveID),我遇到了这个错误:

“/”应用程序中的服务器错误。

数据保护操作不成功。这可能是由于没有为当前线程的用户上下文加载用户配置文件,这可能是线程模拟时的情况。

说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.Security.Cryptography.CryptographicException:数据保护操作不成功。这可能是由于没有为当前线程的用户上下文加载用户配置文件,这可能是线程模拟时的情况。

源错误:

在执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常起源和位置的信息。

堆栈跟踪:

[CryptographicException:数据保护操作不成功。这可能是由于没有为当前线程的用户上下文加载用户配置文件,这可能是线程模拟时的情况。] System.Security.Cryptography.ProtectedData.Protect(Byte[] userData, Byte[] optionalEntropy , DataProtectionScope 范围) +379 System.IdentityModel.ProtectedDataCookieTransform.Encode(Byte[] value) +52

[InvalidOperationException:ID1074:尝试使用 ProtectedData API 加密 cookie 时发生 CryptographicException(有关详细信息,请参阅内部异常)。如果您使用的是 IIS 7.5,这可能是由于应用程序池上的 loadUserProfile 设置设置为 false。] System.IdentityModel.ProtectedDataCookieTransform.Encode(Byte[] value) +167 System.IdentityModel.Tokens.SessionSecurityTokenHandler.ApplyTransforms(Byte[] cookie, Boolean outbound) +57 System.IdentityModel.Tokens.SessionSecurityTokenHandler.WriteToken(XmlWriter writer, SecurityToken令牌)+658 System.IdentityModel.Tokens.SessionSecurityTokenHandler.WriteToken(SessionSecurityToken sessionToken)+86 System.IdentityModel.Services.SessionAuthenticationModule.WriteSessionTokenToCookie(SessionSecurityToken sessionToken)+144 System.IdentityModel。

我应该怎么办 ?我已经正确设置了 URL。我在 web.config 中没有任何对“localhost”的引用。我不知道我必须另外设置什么才能使其正常工作。

4

2 回答 2

0

默认情况下,WIF 使用 DPAPI 来加密 cookie。切换到基于证书的加密。看到这个答案:

是否可以在没有 LoadUserProfile = True 的情况下运行 WIF

于 2013-06-09T01:04:40.083 回答
0

Vittorio Bertocci 在这里回答了这个问题 http://www.cloudidentity.com/blog/2013/01/28/running-wif-based-apps-in-windows-azure-web-sites-4/

DPAPI 在云 Web 应用程序中不可用,4.5 有一个简单的解决方案

于 2014-02-23T20:07:05.433 回答