WCF 4 Rest Getting IP of Request?

后端 未结 1 749
春和景丽
春和景丽 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条回答
  •  梦毁少年i
    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)
提交回复
热议问题