How to use IDispatchMessageInspector in a WCF Service?

前端 未结 5 1723
面向向阳花
面向向阳花 2020-12-10 13:24

I am trying to use IDispatchMessageInspector in a WCF service implementation to access custom header values.

Something like:

public class MyService :         


        
5条回答
  •  北海茫月
    2020-12-10 14:10

    What I did to access the details I set the following inside IDispatchMessageInspector.AfterReceiveRequest

    Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(username, "Membership Provider"), roles);

    I've omitted the authentication code from this.

    To access the value from the service method, you can call

    Thread.CurrentPrincipal.Identity.Name

提交回复
热议问题