Saturday, December 4, 2010

Using ASP.NET Routing Instead of .svc file When Hosting WCF RESTful Service in IIS

 

ASP.NET Routing are generally used because they give you more control over your URI’s . Now let see how we can use this Routing to host WCF RESTful Service.

1) Create a WCF Service Application

2) Delete the .svc file

3) Now add  the following <serviceHostingEnvironment  aspNetCompatibilityEnabled="true" />to web.config file.

Next you need to  decorate the your class as shown below.

image

Now add Global.asax file to your Service Project and define the One Private method called RegisterRoutes.

image

Now call this method in Application_Start.

image

Now you can browse the service  as  http://localhost:5018/SreeniRestSvc

Nandri(Thanks)

Sreenivasaragavan.

No comments: