c# - App.config needs dynamic value -



c# - App.config needs dynamic value -

my app config has line of code.

<add baseaddress = "http://localhost:8733/design_time_addresses/wcfservicelibrary1/service1/" />

however require having localhost equivalent of system.net.dns.gethostname(). ideas on how can done?

i can suggest utilize string.format:

<add baseaddressformat = "http://{0}:8733/design_time_addresses/wcfservicelibrary1/service1/" />

and in code:

var baseaddress = string.format(configurationmanager.appsettings["baseaddressformat "], system.net.dns.gethostname());

or can hide string.format phone call behind global app configuration class property. like:

public class myconfig { public string baseaddress { { homecoming string.format(configurationmanager.appsettings["baseaddressformat "], system.net.dns.gethostname()); } } }

c# .net wcf

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -