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


In VS, go Tools> WCF Service Configuration Editor. You can open your web.config and winker with your WCF endpoints and bindings in a nice GUI that (shouldn't) generate XML that VS will complain about.



+3


a source


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.

enter image description here

+2


a source


Just add System.ServiceModel.dll under your VS project link where your Web.config file is present.

Then add the below code to your Web.config (for example other service endpoints):

<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange"/>

      

+1


a source







All Articles