gpt4 book ai didi

asp.net - IIS 7 日志记录 Web 服务方法

转载 作者:行者123 更新时间:2023-12-04 12:49:02 24 4
gpt4 key购买 nike

我有一个托管在 IIS 7 下的 Web 服务(不是 WCF 服务),该 Web 服务有两种方法:method1 和 method2。

我希望在不修改 Web 服务代码的情况下区分方法 1 的请求和方法 2 的请求。

在 IIS 7 日志下,我可以看到对 Web 服务的请求,Web 服务 URL 记录在“cs-uri-stem”字段下,但“cs-uri-query”字段为空。

无论如何要记录对 Web 服务方法的请求,而不修改 Web 服务代码?

最佳答案

您可以在处理管道的各种方法中记录所有传入请求。例如,为 BeginRequest 添加处理程序在您的 Global.asax :

Application_BeginRequest( object sender, EventArgs e )
{
HttpApplication app = (HttpApplication)sender;
HttpContext ctx = app.Context;

var requestUrl = ctx.Request.Url;

// the uri should be of a form:
// http://yoursite/theservice.asmx/MethodName
}

关于asp.net - IIS 7 日志记录 Web 服务方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8992265/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com