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.
client = new HttpClient();
client.BaseAddress = webApiEndpoint;
}