简体   繁体   中英

WEBAPI client server binding information

If you're developing a WebAPI client where would you store information about the server you're connecting to, assuming that the information will be different in dev, staging and production.

Is it possible to have profiles defined for each deployment environment similar to web application deployment profiles.

In my case, we're building a library that consumes a WEBAPI service that could be deployed either locally, on an intranet or on the cloud

The only thing that i did so far to lessen the problem is to define the server binding information (server address/port) in an App.config . When i build my library i have a mylib.dll and mylib.dll.config that i can customize.

I would have preferred to set the right information at deployment time.

Any ideas from folks who run into similar issues

-ken

If you are using Visual Studio for deployment, have a look Web.config Transformation Syntax for Web Project Deployment Using Visual Studio In VS 2012, right-click your config file and select Add Transform, as simple as that. This will add Web.Debug.config and Web.Release.config (assuming you have standard build configuration) which will be used to apply transformations to Web.config in compile time.

The only disadvantage is that Solution configuration now also points to environment which may be annoying and breaks SRP.

The best approach I know so far is to use Octopus which supports config file transformations in deployment time. This way solution configuration does what it should and nothing else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM