WCF Service throws Http404 on any request except .svc

363 views Asked by At

I have created a WCF Service Library in MVC project and set up MySerice.svc and Web.Config file in project as follow:

<!--added to run WCF service -->
<system.serviceModel>
  <!-- this multipleSiteBindingsEnabled for remote access -->
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="True" />
  <services>
    <service name="SchoolProject.WCF.SchoolProjectService" behaviorConfiguration="ServiceBehaviour">
     

      <endpoint address="" binding="webHttpBinding" contract="SchoolProject.WCF.ISchoolProjectService" behaviorConfiguration="web" />
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="ServiceBehaviour">
        <serviceMetadata httpGetEnabled="True" />
        <serviceDebug includeExceptionDetailInFaults="False" />
      </behavior>
    </serviceBehaviors>
    <endpointBehaviors>
      <behavior name="web">
        <webHttp/>
      </behavior>
    </endpointBehaviors>
  </behaviors>
</system.serviceModel>


<!-- end-->

The problem is when I run MySerice.svc file in browser it works fine but all other request made on http://localost:18457/MyService.svc/Anyrequest shows the error which is as like below: (Note: discard the svc file name and supplied url on picture) enter image description here

I will appreciate if anyone can provide some code snippet. Thank you

1

There are 1 answers

0
Ishwor Khanal On

Luckily I got the answer changing RouteConfig.Cs file as follows From

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

To

routes.IgnoreRoute("{resource}.svc/{*pathInfo}");

as long as you should place your .svc file in root of your application.

It worked for me like a charm. Hope it will help to somebody !! Good Luck