Click here to Skip to main content
15,919,749 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need to create caching profile for web service to enable the webservice to cache it's output if same request is made within a reasonable time.
Thanks In Advance Friends
Posted
Updated 2-May-13 0:49am
v2

1 solution

 
Share this answer
 
Comments
SPASWIN 3-May-13 1:57am    
Thank you Sir ,
but i used the below Configuration ,it doesnt work
***************************
Hosted Service

namespace WcfService6
{
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Required)]
public class Service1
{
[WebGet(UriTemplate = "{abc}")]
[AspNetCacheProfile("CacheFor60Seconds")]
public string getValue(string abc)
{
return abc;
}
}
}
*****************************
web.Config


configuration

appsettings
add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/add
/appsettings
system.web
caching
outputcachesettings
outputcacheprofiles
add name="CacheFor60Seconds" duration="60" varybyparam="none"/add
/outputcacheprofiles
/outputcachesettings
/caching
compilation debug="true" targetframework="4.5"/compilation
httpruntime targetframework="4.5"/httpruntime
/system.web
system.servicemodel
servicehostingenvironment aspnetcompatibilityenabled="true" multiplesitebindingsenabled="true"/servicehostingenvironment
behaviors
servicebehaviors
behavior
servicemetadata httpgetenabled="true" httpsgetenabled="true"/servicemetadata
servicedebug includeexceptiondetailinfaults="false"/servicedebug
/behavior
/servicebehaviors
/behaviors
add binding="basicHttpsBinding" scheme="https"/add
/system.servicemodel
system.webserver
modules runallmanagedmodulesforallrequests="true"/modules
directorybrowse enabled="true"/directorybrowse
/system.webserver

/configuration

********************
i am calling the above service from Client

namespace ConsoleApplication12
{
class Program
{
static void Main(string[] args)
{
ServiceReference1.Service1Client abc = new Service1Client();
string sample="Sample";
for (int i = 0; i < 5; i++)
{
var str = abc.getValue(sample);
Console.WriteLine(str);
}

Console.ReadKey();
}
}
}

**********************
it seems output caching doesnt works ......is there anything wrong???

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900