The .NET Endpoint

Blog by the .NET and AppFabric teams about WCF and WF development, deployment, and management - Getting Control of the URI with RESTful WCF Services - Getting Control of the URI with RESTful WCF Services

  • Comments 2

RESTFul people want to control the URI of their services.  They focus on building a good information architecture that describes the resources their site provides.  Historically most web sites described resources in terms of files and paths in the virtual root of the web server.  But what if your resources are coming from a database and there are no files to speak of?  What is the URI of your service then?

The default behavior of a RESTful web service  in WCF is that you have a SVC file like "MyService.svc" and the first segment of your URI (after the host) is the path to the SVC file on your web site.  The remaining portion of the URI is the name of your method and a query string arguments for the parameters.

For example

You can partially control this URI by applying a URI template.  So for example in this case we could attribute the operation contract with a template like this


This will change the portion of the URI after the .svc extension so our URI will look like this

Nice, but what if you want to eliminate the .svc extension? Well there are several ways you can get this done

My colleague Rob Bagby has created a nice screencast for with a complete walkthrough of controlling the URI that features

Be sure to check it out and build some RESTful WCF Services with the URI just the way you want it.

Page 1 of 1 (2 items)