Search code examples
wcfazure

A property with the name 'httpRequest' is not present


I've ran into an interesting problem using the Azure Service Management API. Specifically, when I try any operation, I get a "Server Error in '/' Application. A property with the name 'httpRequest' is not present. ".

This only happens in one project and I can't reproduce it with creating other projects.

I've tried reading Fusion logs, because I've suspected there's a problem with assembly versions, but it turns out not to be the case. I also tried readding references, which also didn't work.

I'm stuck - does anybody have a clue?

<InnerException i:nil="true"></InnerException>
    <Message>A property with the name 'httpRequest' is not present.</Message>
<StackTrace>
Server stack trace:
    at System.ServiceModel.Channels.MessageProperties.get_Item(String name)
    at Microsoft.Toolkit.WindowsAzure.ServiceManagement.ClientOutputMessageInspector.BeforeSendRequest(Message& request, IClientChannel channel) 
    at System.ServiceModel.Dispatcher.ImmutableClientRuntime.BeforeSendRequest(ProxyRpc& rpc)
    at System.ServiceModel.Channels.ServiceChannel.PrepareCall(ProxyOperationRuntime operation, Boolean oneway, ProxyRpc& rpc)
    at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.Begin()
    at System.ServiceModel.Channels.ServiceChannel.BeginCall(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, TimeSpan timeout, AsyncCallback callback, Object asyncState)
    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeBeginService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
</StackTrace>

Solution

  • The solution is described in detail here. But you need a nudge in the right direction, which is nutoriously difficult to find. We've had the same issue a while ago so I've written a blog post about httpRequest not being present exception (WCF).

    To summarize, wrap your call to the code in:

        using (new OperationContextScope((IContextChannel)channel))
        {
           // ... my code
        }