How does one get the method name from a WCF Request in Application_BeginRequest?
Someone asked on Stack Overflow:
I’m hosting WCF in an IIS, in my HttpApplication I’d like to get the WCF operation contract name (method being called) in the
Application_BeginRequestmethod:protected void Application_BeginRequest(object sender, EventArgs e) { var request = Context.Request; }I get the request from the context but I’m unable to understand how to find the name of the WCF method that was called.
I posted the following answer, which was chosen as the accepted answer:
Check out the incoming HTTP Headers:
Console.WriteLine(HttpContext.Current.Request.Headers["SOAPAction"]);
This will spit out the full value, in my sample that was:
It is probably worth noting, but OperationContext.Current.IncomingMessageHeaders.Action won’t work in Application_BeginRequest because the operation hasn’t started yet, so OperationContext.Current is null.
Originally posted on Stack Overflow — 0 upvotes (accepted answer). Licensed under CC BY-SA.