Wcf请求生命周期

时间:2009-09-03 19:18:48

标签: .net wcf

是否存在WCF请求通过的生命周期?具体来说,我需要能够拦截并可能取消在调用之前所做的请求。

2 个答案:

答案 0 :(得分:6)

您需要实现IDispatchMessageInspector并将其注入serivce行为堆栈。

使用IDispatchMessageInspector.AfterReceiveRequest接受或拒绝请求。

请参阅: http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.idispatchmessageinspector.aspx

http://www.codeproject.com/KB/WCF/WCFIPfilter.aspx

答案 1 :(得分:1)

您可以在

中编写代码
void Application_BeginRequest(object sender, EventArgs e)
    {
    }

OR

void Application_EndRequest(object sender, EventArgs e)
    {
    }

服务器端的global.asax中的事件。

相关问题