/    Sign up×
Community /Pin to ProfileBookmark

use ConfigurationManager to call the value of a custom tag in app.config

I created a Rest web API and now I want to call the operations exposed by the API from a Proxy. My environment is Visual Studio, C#.

As the operations that I exposed in the API share a part of the URL/endpoint (“_api/NameOfTheController_“), I want to refer to this piece of URL by creating a custom tag in the _app.config_ file of the Proxy project; I’m gonna call it by using ConfigurationManager to initialize a property of the Proxy.

How should I use the ConfigurationManager class to call the value of the custom tag?

What I have tried:

In the app.config of the proxy I wrote thee following tag, inside the <client> tag:

`<customEndpointSegment name = “/api/NameOfTheController” />
`

Inside the same <client> tag there is a <endpoint> tag which points to another different service too.

In the Proxy.cs I have the following:

“`
string webApiEndpoint;
HttpClient client;

public RestProxy()
{
webApiEndpoint = ConfigurationManager. // I have to call the value of the tag here
client = new HttpClient();
client.BaseAddress = webApiEndpoint;
}
“`

to post a comment

1 Comments(s)

Copy linkTweet thisAlerts:
@xhonauthorNov 23.2020 — ["use ConfigurationManager to call the value of the custom tag in app.config","use ConfigurationManager to call the value of a custom tag in app.config"]
×

Success!

Help @xhon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...