小编Rya*_*vis的帖子

带有 Web.API 2 的 MiniProfiler;是否有全局魔术请求上下文对象?

我正在尝试在我的 web api 站点上设置 MiniProfiler,并且很难MiniProfiler.Current开始工作。

我按照 miniprofiler.com 上的指示,在 global.asax 中有以下内容:

protected void Application_Start()
{
  MiniProfilerEF6.Initialize();
  // other setup
}
protected void Application_BeginRequest() {
  // need to start one here in order to render out the UI
  MiniProfiler.Start();
}
protected void Application_EndRequest() {
  MiniProfiler.Stop();
}
Run Code Online (Sandbox Code Playgroud)

这使用默认的WebRequestProfilerProvider,它将实际的配置文件对象存储在HttpContext.Current.Items.

当我要求时MiniProfiler.Current,它看起来像HttpContext.Current

当我请求我的 Web api URL 之一时:

  • Application_BeginRequest 创建分析器,将其存储在 HttpContext.Current
  • 在 web api 中MessageHandler,我可以看到HttpContext.Current
  • 在网络 apu 中IActionFilterHttpContext.Current现在为空,我的尝试MiniProfiler.Current.Step("controller:action")失败了 …

httpcontext action-filter mvc-mini-profiler asp.net-web-api

5
推荐指数
1
解决办法
3233
查看次数

COM"获取属性"具有多个参数

我试图从python中调用WindowsInstaller.Installer.ProductsEx,并且无法弄清楚如何使其工作.

这是我想从python调用的vbscript版本:

dim msi, products
set msi = CreateObject("WindowsInstaller.Installer")
set products = msi.ProductsEx("", "s-1-1-0", 7)
Run Code Online (Sandbox Code Playgroud)

我认为我的问题是ProductsEx一个带有3个参数的只读get属性,我不知道如何说服win32comcomtypes以这种方式调用它.

我试过了:

>>> import win32com.client
>>> msi = win32com.client.Dispatch('WindowsInstaller.Installer')
>>> products = msi.ProductsEx('', 's-1-1-0', 7)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<COMObject WindowsInstaller.Installer>", line 2, in ProductsEx
pywintypes.com_error: (-2147352573, 'Member not found.', None, None)
Run Code Online (Sandbox Code Playgroud)

和类似的使用comtypes:

>>> import comtypes.client
>>> msi = comtypes.client.CreateObject('WindowsInstaller.Installer')
>>> products = msi.ProductsEx['', 's-1-1-0', 7]
Traceback …
Run Code Online (Sandbox Code Playgroud)

python com comtypes win32com

5
推荐指数
1
解决办法
466
查看次数