Search code examples
wcfcookieswebsocket

WCF WebSocketService read cookies


I have a WCF service (inheriting from WebSocketService) hosted in IIS. I'm trying to get cookies from the request I'm handling in "OnMessage".

I tried using:
- WebSocketContext.CookieCollection - HttpContext.Current.Request (Current is NULL) - OperationContext.Current.IncomingMessageProperties

None of them worked. I'm probably missing something in the web.config file or something else. I'll appreciate any help.

Thanks


Solution

  • I am not completely sure about this, but enable ASP.NET compatiblity:

    <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    </system.serviceModel> 
    

    And then check HttpContext.Current.Request.

    The cookies are sent in the HTTP handshake, not with every message.