My requirement is to call WCF web service from ASP.NET code behind and pass some data for example:
void Add(int x, int y);
Result of the operation should be somehow stored within WCF web service (member variable). Later user should be able to call
double Equals();
and get the result of the operation. Of course since it's an open website many non-authenticated users can open the ASP.NET page and call the web service.
Alternatively Add method can return "key" that can be used to get result back, for example :
Guid Add(int x, int y);
double Equals(Guid key);
I don't think I can use WCF sessions since web service will think that there is only 1 client ( WebSite calling the webserivce hosted in IIS ).
Users are not authenticated - they are anonymous users.
I could use : ( please take a look at my EDIT )
InstanceContextMode =InstanceContextMode.Single
as attribute over my web service and store Dictionary<key, result>
but the problem is when can I remove entry from Dictionary?
Should I use some sort of BackgroundWorker to check dictionary every e.g. 15 minutes and remove old entries? In that case I would have to store DateTime against each entry but that's not a problem if this is the best way to implement this solution...
My example Add/Equals methods are only to illustrate the problem, real requirement need to store much more data per user than simple double
result
Thanks in advance for all the help.
EDIT:
After thinking more about the InstanceContextMode =InstanceContextMode.Single
I think it's not the best option to use with ASP.NET since if 100 users will call the web service at the same time I will get 100 sequential invocations which will cause performance issues.
In that case do you have any ideas how to implement this without changing InstanceContextMode setting (which by default is PerSession as far as I know) ?