0
我嘗試實現自定義服務行爲以從響應消息中獲取Cookie。我在AfterReceiveRequest方法中創建了一個斷點。它從未被擊中。怎麼了 ? 我認爲需要註冊服務的服務行爲。怎麼樣 ?
實現自定義服務行爲
行爲:
public class HttpResponseMessageInspector : BehaviorExtensionElement, IDispatchMessageInspector, IServiceBehavior
{
public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
{
//Here is my breakpoint
return null;
}
}
的Web.config
<extensions>
<behaviorExtensions>
<add name="HttpResponseMessageInspector" type="MyNamespace.HttpResponseMessageInspector, myassembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior>
<HttpResponseMessageInspector/>
</behavior>
</serviceBehaviors>
</behaviors>
服務註冊
RouteTable.Routes.Add(new ServiceRoute("Customers", new NinjectWebServiceHostFactory(), typeof(CustomersService)));
RouteTable.Routes.Add(new ServiceRoute("Companies", new NinjectWebServiceHostFactory(), typeof(CompaniesService)));
這可能有所幫助:http://www.codeproject.com/Articles/190806/Send-Cookies-When-Making-WCF-Service-Calls – 2013-03-26 11:42:04
不要。不管怎麼說,還是要謝謝你。 – 2013-03-26 11:47:41