WCF Service throws Http404 on any request except .svc
Asked Answered
C

1

0

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

Censorious answered 13/12, 2016 at 3:33 Comment(0)
C
1

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

Censorious answered 13/12, 2016 at 3:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.