Caching and Automatic Help Page
This sample demonstrates the following:
How to create a REST service using WCF REST features.
How to enable the service to automatically generate a help Web page.
How to declaratively specify what caching capabilities you need.
Creating a REST Service
The sample demonstrates how to expose a singleton resource by using a WCF REST service that acts as a counter that manages the HTTP verbs.
The sample does the following actions.
Create the counter with an initial value or increment the counter by a specified value by calling HTTP-POST.
Updates the counter value using HTTP-PUT.
Retrieves the counter value by calling HTTP-GET.
Deletes the counter by calling HTTP-DELETE.
The sample also shows how you can get the same resource to return different representations (XML and JSON) based on the URL.
Enabling Automatic Help Page
The sample demonstrates how to automatically enable a help page as an HTML web page for your WCF REST service with a single configuration entry. The help page shows the different URI templates supported, the different request and response formats (XML and JSON are shown) supported, as well as schema and examples of messages in the supported formats.
The sample demonstrates how to specify declarative caching using the ASP .NET Output Cache profile mechanism. Specifically, you set an attribute on the method whose response you want to be cached, and refer to an Output Cache profile that you specify in the configuration file. You can also set an attribute to specify whether you want each format to be cached separately.
To use this sample
Using Visual Studio 2010, open the Counter.sln solution file.
To build the solution, press F6.
To run the solution, press CTRL+F5.
You can also deploy the sample to Internet Information Services (IIS) and invoke it from the browser.
To see the help page, run the service as previously shown, and then click the .svc file. Suffix the URL in the address bar with
/helpto see the help page.
The samples may already be installed on your machine. Check for the following (default) directory before continuing.
If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.
Build Date: 2010-02-04