gpt4 book ai didi

azure - Azure 网站上的 SignalR CryptographicException

转载 作者:行者123 更新时间:2023-12-01 19:18:58 24 4
gpt4 key购买 nike

我在 Azure 网站中部署的 SignalR 中遇到了此异常。在调试环境下运行良好。它是 SignalR 1.0.1,我使用 .NET MVC 和 WebApi

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.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: 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.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[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.]
Microsoft.Owin.Host.SystemWeb.<>c__DisplayClass1.<GetRethrowWithNoStackLossDelegate>b__0(Exception ex) +27
Microsoft.Owin.Host.SystemWeb.Utils.RethrowWithOriginalStack(Exception ex) +15
Microsoft.Owin.Host.SystemWeb.CallContextAsyncResult.End(IAsyncResult result) +47
Microsoft.Owin.Host.SystemWeb.OwinHttpHandler.EndProcessRequest(IAsyncResult result) +7
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9629708
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

你有什么想法吗?谢谢

最佳答案

对于访问此页面的其他人,我也遇到了同样的问题,但解决方案要简单得多。正如上面评论中提到的,接受的答案很糟糕。还提到,SignalR 默认使用 MachineKeyDataProtector 作为 IProtectedDataMapHubsMapConnection 都调用一个函数 InitializeProtectedData,该函数向依赖解析器注册 MachineKeyDataProtector

我的问题是我正在映射我的 SignalR 路由,然后配置依赖项解析器

RouteTable.Routes.MapConnection<SomeEndpoint>("SomeEndpoint", "SomeEndpointUrl");
GlobalHost.DependencyResolver =
new StructureMapDependencyResolver(ObjectFactory.Container);

所以基本上,当我注册自定义解析器时,由 MapConnection -> InitializeProtectedData 完成的 IProtectedData 解析器注册被震撼了。简单修复,在映射连接之前设置解析器。

GlobalHost.DependencyResolver = 
new StructureMapDependencyResolver(ObjectFactory.Container);
RouteTable.Routes.MapConnection<SomeEndpoint>("SomeEndpoint", "SomeEndpointUrl");

关于azure - Azure 网站上的 SignalR CryptographicException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15393684/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com