كيفية استرداد اسم آلة العميل من داخل عقد تشغيل WCF؟

StackOverflow https://stackoverflow.com/questions/5034660

  •  15-11-2019
  •  | 
  •  

سؤال

أنا أتطلع حاليا إلى OperationContect.current خصائص.هل هناك خاصية (متداخل)، ستعود دائما اسم الجهاز للعميل؟أنا حاليا باستخدام NET.TCP ملزمة، ولكن أود دعم الارتباطات الإضافية في المستقبل.

باستخدام .NET 3.5 SP1

هل كانت مفيدة؟

المحلول

You can get the remote endpoint's IP address from the current OperationContext's IncomingMessageProperties, eg:

RemoteEndpointMessageProperty messageProperty = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
Console.WriteLine("Remote address is: {0}", messageProperty.Address);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top