So in WCF 4.0 Features - Three, we discussed Routing service. Now let's move to next...
Help page lists a description of each operation, request and response formats.This functionality is turned off by default. When a user browses to a WCF WEB HTTP service and appends "/Help" on to the end of the URL, for example http://localhost:8000/Customers/Help, a help page like the following is displayed.
The user can then click any method listed in the help page and detailed page for that operation is displayed showing more information about the method, including message formats and example responses. The following image is an example of a help page for a method.
We have to add <webHttp helpEnabled="true" /> in Cconfiguration behaviors.
[AspNetCacheProfile("CacheFor60Seconds")]
With this in place, you’ll need to define an ASP.NET output caching profile named “CacheFor60Seconds” within your web.config file. The following web.config shows how this can be done:
<configuration>
<system.web>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="CacheFor60Seconds" duration="60" varyByParam="format" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
</configuration>
Same Can be achieved programmatically as follows :
using (WebServiceHost host = new WebServiceHost(typeof(Service), new Uri("http://localhost:8000/Customers")))
{
host.AddServiceEndpoint(typeof(ICustomerCollection), new WebHttpBinding(), "");
host.Description.Endpoints[0].Behaviors.Add(new WebHttpBehavior { EnableHelp = true });
}
So in WCF 4.0 Features series we discussed some basic new features thanks for reading...
Courtesy: Random Web Images, MSDN, Microsoft .NET 4.0 WCF Book, Several online resources
Improved REST Support...
WCF 4 comes with several Improved REST Support like an automatic help page that describes the RESTful service to consumers, simplified HTTP caching etc.Help page lists a description of each operation, request and response formats.This functionality is turned off by default. When a user browses to a WCF WEB HTTP service and appends "/Help" on to the end of the URL, for example http://localhost:8000/Customers/Help, a help page like the following is displayed.
The user can then click any method listed in the help page and detailed page for that operation is displayed showing more information about the method, including message formats and example responses. The following image is an example of a help page for a method.
We have to add <webHttp helpEnabled="true" /> in Cconfiguration behaviors.
HTTP Caching...
One of the primary potential benefits of REST is HTTP caching to leverage the various HTTP caching header, apply the [AspNetCacheProfile] attribute to a [WebGet] operation as follows:[AspNetCacheProfile("CacheFor60Seconds")]
With this in place, you’ll need to define an ASP.NET output caching profile named “CacheFor60Seconds” within your web.config file. The following web.config shows how this can be done:
<configuration>
<system.web>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="CacheFor60Seconds" duration="60" varyByParam="format" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
</configuration>
Same Can be achieved programmatically as follows :
using (WebServiceHost host = new WebServiceHost(typeof(Service), new Uri("http://localhost:8000/Customers")))
{
host.AddServiceEndpoint(typeof(ICustomerCollection), new WebHttpBinding(), "");
host.Description.Endpoints[0].Behaviors.Add(new WebHttpBehavior { EnableHelp = true });
}
So in WCF 4.0 Features series we discussed some basic new features thanks for reading...
Courtesy: Random Web Images, MSDN, Microsoft .NET 4.0 WCF Book, Several online resources