How do I obtain the endpointIdentity from the config file?
You could load up your web.config file using WebConfigurationManager, get the <client>
section, and then find the appropriate <endpoint>
element (by name or by address or whatever) and then drill into it to find the DNS value:
ClientSection clientSection = (WebConfigurationManager.GetSection("system.serviceModel/client") as ClientSection);
foreach(ChannelEndpointElement cee in clientSection.Endpoints)
{
if(cee.Name == "ConfigurationManagerTcp")
{
IdentityElement ie = cee.Identity;
string dnsValue = ie.Dns.Value;
}
}
You'll need to use the System.Web.Configuration
and System.ServiceModel.COnfiguration
namespaces for the classes involved.
Marc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With