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)
I will appreciate if anyone can provide some code snippet. Thank you
Luckily I got the answer changing RouteConfig.Cs file as follows From
To
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