Condividi tramite


How to do authorization based on the body content

This is a forum question, and here is a very sneaky way to do so.

protected override bool CheckAccessCore(OperationContext operationContext)

{

    string msgStr = operationContext.RequestContext.RequestMessage.ToString();

    Message msg = Message.CreateMessage(XmlTextReader.Create(new StringReader(msgStr)), int.MaxValue, operationContext.RequestContext.RequestMessage.Version);

    Console.WriteLine(msg.GetReaderAtBodyContents().ReadOuterXml());

 

    return true;

}

Hope it helps!