Get address from C # help desk

I have a project that has a service link to a web service. Is there any way from the code to get the actual http address of the help desk?

thanks

+4
source share
2 answers

You can get it from the proxy server of the client that was generated for you:

using (var client = new ServiceReference1.MyServiceClient("*")) { string address = client.Endpoint.Address.Uri.ToString(); } 

or if there are several endpoints in your configuration file:

 using (var client = new ServiceReference1.MyServiceClient("MyService")) { var address = client.Endpoint.Address.Uri.ToString(); } 
+8
source

Yes, the generated proxy will have the Url property.

+1
source

Source: https://habr.com/ru/post/1398242/


All Articles