Rap*_*aph 3 azure signalr asp.net-web-api azure-web-sites signalr-hub
我使用部署在Azure WebSites中的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
Run Code Online (Sandbox Code Playgroud)
你有什么主意吗 ?谢谢
对于其他人来到这个页面,我有同样的问题,但解决方案更简单.正如上面的评论所述,接受的答案很糟糕.还提到的是,SignalR默认使用MachineKeyDataProtector的IProtectedData.MapHubs并且MapConnection都调用一个向依赖项解析器InitializeProtectedData注册的函数MachineKeyDataProtector.
我的问题是我正在映射我的SignalR路由,然后配置依赖解析器
RouteTable.Routes.MapConnection<SomeEndpoint>("SomeEndpoint", "SomeEndpointUrl");
GlobalHost.DependencyResolver =
new StructureMapDependencyResolver(ObjectFactory.Container);
Run Code Online (Sandbox Code Playgroud)
因此,当我注册我的自定义解析器时,MapConnection - > InitializeProtectedData完成的IProtectedData解析器注册基本上已经被吹走了.简单修复,在映射连接之前设置解析器.
GlobalHost.DependencyResolver =
new StructureMapDependencyResolver(ObjectFactory.Container);
RouteTable.Routes.MapConnection<SomeEndpoint>("SomeEndpoint", "SomeEndpointUrl");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1789 次 |
| 最近记录: |