views:

17

answers:

1

I'm trying to test my REST service with WebCache attribute

[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public partial class MyContract : IMyContract
    {
        [OperationContract()]
        [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "items/{code}"
        [WebCache(CacheProfileName = "NoCacheProfile")]
        public ItemDTO GetItem(string code)

when i try to open the host

WebServiceHost host = new WebServiceHost2(typeof(MyContract), true, new Uri("http://localhost:7777/MySvc"));
host.Open();

i get the following exception

[System.NotSupportedException] = {"WebCacheAttribute is supported only in AspNetCompatibility mode."}

A: 

If WebCacheAttribute is supported only in AspNetCompatibility mode, you may need to declare AspNetCompatibilityRequirementsMode = Required in "AspNetCompatibilityRequirements" attribute and check the service configuration in Web.config to ensure it is enabled:

 <system.serviceModel>        
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />    
</system.serviceModel>

For more information, please visit: http://msdn.microsoft.com/en-us/library/aa702682.aspx

ZEAXIF