Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1091241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:29:41+00:00 2026-05-16T23:29:41+00:00

My requirement is to call WCF web service from ASP.NET code behind and pass

  • 0

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) ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:29:42+00:00Added an answer on May 16, 2026 at 11:29 pm

    I think,Keeping the

    InstanceContextMode =InstanceContextMode.Single 
    

    as the service behavior, if your architecture permits, you can use the System.Web.Caching.Cache object implemented in a static class(so that it will be instantiated only once) ,where you can specify the cache dependency/expiration time etc and hence you can get the complete set of functionalities offered from the cache service, instead of implementing on your own.

    Edit:
    If your primary intention is about Caching, then you need not use the Instance Context mode even. You can simply implement your own static Cache provider based on the System.Web.Caching.Cache and pass the cacheKey as shown in the following sample:

     public int Add(int a, int b)
            {
                string cacheKey = a.ToString()+b.ToString();
                if (!CacheProvider.Contains(cacheKey))
                {
                    CacheProvider.Add(cacheKey, a + b);
                    return a + b;
                }
                else
                {
                    return (int)CacheProvider.GetValue(cacheKey);
                }
    
            }
    

    CacheProvider in the above code is the static implementation of your Cache provider.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement to call a dll (unmanaged c) from a .NET web
We have a requirement to call a WCF service from another WCF Service. To
I'm developing an ASP.Net mvc application which has a requirement to do some small,
A requirement for an ASP.Net 2.0 project I'm working on limits a certain field
I've got a WSE 3.0 web service that I'm trying to call using a
I need to make call to a WCF service in a Transaction scope. I
I have my WCF service, I've created reference to it from MSTest project. Here
I have the requirement to call an internal method of a 3rd party object
My requirement is I have server J2EE web application and client J2EE web application.
My requirement is just to display a set of values retrieved from database on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.