小编toz*_*evv的帖子

从System.Net.Http.DelegatingHandler调用时,MiniProfiler.Current为null

我在我的asp.net Web API项目中使用迷你探查器,并希望跟踪在自定义DelegatingHandler中运行的某些代码的性能.

MiniProfiler.Current.Step()内部的调用DelegatingHandler不会显示在结果中.同一项目中的其他调用显示正常.

进一步的调查显示,MiniProfiler.Current是从中获取HttpContext.CurrentWebRequestProfilerProvider.而HttpContext.Current从调用时为空 DelegatingHandler.

有没有更好的方法来检索MiniProfiler.Current,以便它在处理程序内部工作?

mvc-mini-profiler asp.net-web-api

12
推荐指数
1
解决办法
1377
查看次数

StackExchange.Redis无法与Mac OS X中的Mono连接

我正在尝试使用以下选项在Mac OS X上的Mono上运行一个非常简单的Redis客户端:

var configOptions = new ConfigurationOptions() 
{
    EndPoints =
{
    { "localhost", 6379 },
},
ResolveDns = true,
KeepAlive = 180
};
StringWriter sw = new StringWriter();
ConnectionMultiplexer.Connect(configOptions, tw);
Run Code Online (Sandbox Code Playgroud)

它无法连接.这是跟踪:

localhost:6379,keepAlive=180,resolveDns=True

Using DNS to resolve 'localhost'...
'localhost' => 127.0.0.1
1 unique nodes specified
Requesting tie-break from 127.0.0.1:6379 > __Booksleeve_TieBreak...
Allowing endpoints 00:00:01 to respond...
127.0.0.1:6379 faulted: UnableToResolvePhysicalConnection on PING
127.0.0.1:6379 failed to nominate (Faulted)
> UnableToResolvePhysicalConnection on GET
No masters detected
127.0.0.1:6379: Standalone v2.0.0, master; keep-alive: 00:03:00; int: …
Run Code Online (Sandbox Code Playgroud)

c# mono redis stackexchange.redis

7
推荐指数
2
解决办法
2816
查看次数

Autofac全局接口拦截器与Autofac.Extras.DynamicProxy2

我正在使用Autofac DynamicProxy2的接口拦截器,我能够为每个寄存器启用接口拦截器:

   var registration = builder.RegisterType<AType>().As<AInterface>();
   registration.EnableInterfaceInterceptors().InterceptedBy<AInterceptor>()
Run Code Online (Sandbox Code Playgroud)

我想对所有注册类型应用某些特征.就像是:

   var registrations = builder.GetAllRegistrations(); // ops, this does not exist...
   foreach (var registration in registrations) {
       registration.EnableInterfaceInterceptors().InterceptedBy<AInterceptor>()
   }
Run Code Online (Sandbox Code Playgroud)

我无法找到获得所有注册的方法.我知道我们可以这样做:

   builder.RegisterCallback(cr =>
   {
       foreach (var registration in cr.Registrations)
       {
            // registration is IComponentRegistration
       }
   });
Run Code Online (Sandbox Code Playgroud)

但这里的注册是一个IComponentRegistration,我需要一个IRegistrationBuilder申请EnableInterfaceInterceptors().

c# autofac

5
推荐指数
2
解决办法
6067
查看次数