Enable MEX in Web.Config
How do I enable / create a MEX endpoint in the below web config so that I can view the service from my browser?
I've tried several options from googling, but VS always complains about this. (not a valid child, etc.)
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service name="MyApp.MyService" behaviorConfiguration="WebServiceBehavior">
<endpoint address="" binding="webHttpBinding" contract="MyApp.IMyService" behaviorConfiguration="JsonBehavior">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="JsonBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Cheers, Conor
+2
a source to share
3 answers
Add this line to web.config right below the service endpoint:
<endpoint address="mex" binding="mexHttpBinding" name="MetadataEndpoint"
contract="IMetadataExchange" />
Thanks to josh3736 for the hint in the GUI editor, the only problem I ran into, I still didn't know how to use the editor for this, so this is what I did:
- In VS open Tools / WCF Service Configuration Editor
- Open the web.config or app.config file containing your service definition
- Go to Services / (your service) / Endpoints folder
- If a MetadataEndpoint exists , click on it and edit the configuration to your liking, otherwise right-click the Endpoint folder , then click New Service Endpoint and configure as shown in the picture below.

+2
a source to share