Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

relationship between configuration in app.config or web.config and code in WCF

Tags:

c#

wcf

How does a service host in WCF interact with the configuration from the web.config or app.config. When I create a service host I only specify an url in the service host constructor and the class of the service.

But in the app.config or web.config I have another list of endpoints, each with it's own specific url. So how does wcf handle this situation? Which endpoint does it take from the app.config or web.config?

like image 733
Alecu Avatar asked Apr 05 '13 07:04

Alecu


People also ask

Is app config and web config are same?

You can have a web. config for each folder under your web application. app. config is used for windows applications.

What is the difference between web config and Machine config?

config ? The web. config files specify configuration settings for a particular web application, and are located in the application's root directory; the machine. config file specifies configuration settings for all of the websites on the web server, and is located in $WINDOWSDIR$\Microsoft.Net\Framework\Version\Config.

What is configuration in web config?

A configuration file (web. config) is used to manage various settings that define a website. The settings are stored in XML files that are separate from your application code. In this way you can configure settings independently from your code.

What is web config file Why do we use web config file?

The web. config is a file that is read by IIS and the ASP.NET Core Module to configure an app hosted with IIS.


1 Answers

The address of the endpoint is relative to the base address of the service host. For example, if you had these endpoints:

<service name="MyService">
    <endpoint address="" binding="ws2007HttpBinding" contract="IMyService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>

and a service host url of http://localhost:7777, then you would be exposing your service on http://localhost:7777, and the metadata on http://localhost:7777/mex.

like image 140
Christian Hayter Avatar answered Oct 06 '22 20:10

Christian Hayter