2

In my WCF client code I add a message inspector (using an IEndpointBehavior).

class MyBehavior : IEndpointBehavior
{
    public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
    {
        clientRuntime.ClientMessageInspectors.Add(new MyMessageInspector());
    }
}

public class MyMessageInspector : IClientMessageInspector
{
    public object BeforeSendRequest(ref Message request, IClientChannel channel)
    {
        Console.WriteLine(request.Properties.ContainsKey(HttpRequestMessageProperty.Name));
    }
}

Now here comes the part I do not understand:

  • When I make a WCF call using a proxy configured to use this behavior, the following happens:

    • If the call is made from a process running inside the VS2015 debugger, True is printed to the console, meaning request.Properties["httpRequest"] is present.
    • If the call is made from a process running normally (not in the debugger), False is printed to the console.

Why is WCF configured differently when running inside/outside the VS2015 debugger? How does this happen? Is it documented anywhere?

codeape
  • 97,830
  • 24
  • 159
  • 188
  • Some info here: http://stackoverflow.com/questions/26209220/property-httprequest-not-present "Apparently, when you run in the debugger, something it does initializes the HttpRequestMessageProperty, but when you run in a regular runtime environment, this Message property does not get initialized." – Quantic Mar 03 '16 at 20:38
  • Is it something to do with the IIS Express host that is being used by VS? I assume you are publishing it to IIS full? I am just guessing... – Dominic Cotton Mar 08 '16 at 11:50
  • @DomCotton This is a WCF client, a console app, so service hosting is not the issue here – codeape Mar 09 '16 at 08:22

0 Answers0