WCF 4 Rest Getting IP of Request?

后端 未结 1 748
春和景丽
春和景丽 2020-12-30 00:22

Hey, how do you get the IP address of the person making a request in something like the following:

    [ServiceContract]    
    [AspNetCompatibilityRequirem         


        
相关标签:
1条回答
  • 2020-12-30 00:55

    Inside AddNewUser use following snippet:

    OperationContext context = OperationContext.Current;
    MessageProperties messageProperties = context.IncomingMessageProperties;
    RemoteEndpointMessageProperty endpointProperty =
      messageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
    

    RemoteEndpointMessageProperty instance offers Address and Port properties.

    0 讨论(0)
提交回复
热议问题