相当于Response.AppendToLog的ISAPI

In ASP.NET the Response object has a very useful method called AppendToLog. It was also around in the Classic ASP days. The Response object hangs off the HttpContext. If you're running with the context of an HttpRequest you can always get ahold of the current HttpContext via the static HttpContext.Current.

在ASP.NET中,Response对象具有一个非常有用的方法,称为AppendToLog 。 在经典ASP时代也是如此。 Response对象挂在HttpContext之上。 如果您正在运行HttpRequest的上下文,则始终可以通过静态HttpContext.Current获得当前的HttpContext

However, not everyone executes within managed code in ASP.NET. We've got a bunch of ISAPI code that is all C++/ATL/MFC. Within MFC you can get ahold of the context via the CHttpServerContext class. This class isn't as friendly as the whole Request/Response ASP model.

但是,并非所有人都在ASP.NET中的托管代码中执行。 我们有一堆都是C ++ / ATL / MFC的ISAPI代码。 在MFC中,您可以通过CHttpServerContext类获取上下文。 此类不如整个请求/响应ASP模型友好。

If you want to get to the really useful stuff you have to run through a 3rd Class API actually named ServerSupportFunction that's hanging off an Extension Control Block. Lame. The second parameter is a DWORD that indicates the function you're trying to call. Since we were trying to call the equivalent of Response.AppendToLog we would use HSE_APPEND_LOG_PARAMETER. The additional information you're trying to log will show up in the

如果您想了解真正有用的东西,则必须通过实际上名为ServerSupportFunction3rd Class API运行,该API悬在Extension Control Block之外。 瘸。 第二个参数是DWORD,它指示您尝试调用的函数。 由于我们试图调用Response.AppendToLog的等效项,因此我们将使用HSE_APPEND_LOG_PARAMETER 。 您尝试登录的其他信息将显示在

So, doing this in managed code:

因此,在托管代码中执行此操作:

HttpContext.Current.Response.AppendToLog(strFoo); HttpContext.Current.Response.AppendToLog(strFoo);

Is this in unmanaged "classic" C++ ISAPI:

这是在不受管理的“经典” C ++ ISAPI中:

m_pCHttpServerContext->m_pECB->ServerSupportFunction(                                 m_pCHttpServerContext->m_pECB->ConnID ,                                 HSE_APPEND_LOG_PARAMETER ,                                 szFoo,                                 &dwFooLen ,                                 NULL                             );

m_pCHttpServerContext-> m_pECB-> ServerSupportFunction( m_pCHttpServerContext-> m_pECB-> ConnID, HSE_APPEND_LOG_PARAMETER, szFoo, &dwFooLen, 空值);

Big ups to Paul Gomes from Corillian for figuring this out! And no I'm not off vacation yet; my wife is asleep. :)

大起大落,从保罗Corillian公司的戈麦斯弄清这一点! 不,我还没有休假; 我老婆睡着了。 :)

翻译自: https://www.hanselman.com/blog/the-isapi-equivalent-of-responseappendtolog

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值