本文介绍了SignalR CryptographicException上AzureWebsites的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到这个例外与SignalR,部署在Azure的网站。它工作在调试环境的罚款。这是SignalR 1.0.1我用.NET MVC和的WebAPI

I got this exception with SignalR, deployed in Azure WebSites. It works fine in debug environment. It's SignalR 1.0.1 and I use .NET MVC and 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

你有什么想法?
谢谢

Do you have any idea ?Thanks

推荐答案

对于其他人来到这个页面,我有同样的问题,但解决的办法就简单多了。如在注释如上所述,接受的答案是坏的。还提到的是,SignalR默认使用 MachineKeyDataProtector IProtectedData MapHubs MapConnection 都调用一个函数 InitializeProtectedData 哪些寄存器 MachineKeyDataProtector 的依赖解析器。

For others coming to this page, I had the same issue but the solution was much simpler. As mentioned in comments above, the accepted answer is bad. Also mentioned is that SignalR defaults to use MachineKeyDataProtector for IProtectedData. MapHubs and MapConnection both call a function InitializeProtectedData which registers MachineKeyDataProtector with the dependency resolver.

我的问题是,我是我的映射路线SignalR,然后配置依赖解析器

My problem was that I was mapping my SignalR routes, and THEN configuring the dependency resolver

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

所以基本上由MapConnection完成IProtectedData解析器注册 - > InitializeProtectedData越来越被风吹走的时候我注册了我的自定义解析器。简单的修复,将解析器映射之前的连接。

So basically the IProtectedData resolver registration done by MapConnection -> InitializeProtectedData was getting blown away when I registered my custom resolver. Simple fix, set the resolver BEFORE mapping the connection.

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

这篇关于SignalR CryptographicException上AzureWebsites的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 03:19