Create a new WCF service application.

Add Global.asax file.

In Application_Start method add below lines:
RouteTable.Routes.Add(new ServiceRoute("api/Service1", new WebServiceHostFactory(), typeof(Service1)));
Add reference of System.ServiceModel.Activation.
Add WebInvoke in Operation Contract of Service Contract (interface IService1).
[OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "/GetData?value={value}")]
Build and browse Project.
Open /api/Service1/GetData?value=5555
Although if you browse Service.svc it will still be served. To disable Service.svc URL follow below steps:
- Right click Service1.svc click View Markup.
- Add Factory="System.ServiceModel.Activation.WebServiceHostFactory" in Service markup.
Browse /Service1.svc
comments powered by
Disqus