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

  • Home
  • SEARCH
  • 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 7604369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:53:32+00:00 2026-05-30T23:53:32+00:00

I have a WCF service code like this: [ServiceContract] [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode =

  • 0

I have a WCF service code like this:

[ServiceContract]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, 
    ConcurrencyMode = ConcurrencyMode.Multiple)]
public class SomeService
{
    public string Password { [OperationContract] get; [OperationContract] set; }

    public void CheckPassword()
    {
        if (Password == null || Password != "password")
            throw new FaultException("Invalid Password");
    }

    [OperationContract] 
    public string SomeMethod()
    {
        this.CheckPassword();

        return "Some Data";
    }
}

And the client windows application consumes it like this:

public class ClientClass
{
    public ClientClass()
    {
        STASomeService.Value.SomeMethod();
    }
}
public class ClientClass
{
    public ClientClass()
    {
        STASomeService.Value.set_Password("password");
    }
}

How can I reset the value of SomeService.Password whenever the SomeService class is instantiated? I do not want an attacker to access my service methods, but when the actual client set the password, the passwords stays in the SomeService.Password property in every service call. But I want to retain the Password value per instance because the client needs that.

My code is in C#, framework 4, build in VS2010 Pro.

Please help. Thanks in advance.

  • 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-30T23:53:34+00:00Added an answer on May 30, 2026 at 11:53 pm

    You shouldn’t have to reset the value of SomeService.Password because it isn’t static. Are you seeing something to the contrary?


    Since you’re using InstanceContextMode.Single (which I originally overlooked), your best recourse my be to mock the behavior of having individual instances in your network bound singleton. The only way I can think of to facilitate this is to have a proxy service class that matches your service’s contracts and delegates its calls to custom instances based on specific criteria (which would define the session). It would be cumbersome to maintain this way and adds a unnecessary level of abstraction, but (in my head at least) it should work

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

Sidebar

Related Questions

I have a WCF service which has one method returning a stream. [ServiceContract] public
I have a WCF service hosted on IIS and it accepts connection like this
I have A WCF service that has a class that inherits System.Web.Security.RoleProvider. In this
I have a WCF service and without changing any code on the client side,
I have the following code in WCF service to throw a custom fault based
I have a piece of code that calls a WCF service that is hosted
I have written a very simple WCF service, that worked fine (code below), then
I got a usual WCF service set up like this: private ServiceHost serviceHost =
I have the below code for returning back an instance of my WCF Service
Imagine I have the following, standard WCF, code : [ServiceContract] interface ICustomerService { [OperationContract]

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.