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 3796916
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:19:01+00:00 2026-05-19T13:19:01+00:00

I need to create a WCF service that is hosted in IIS, uses http

  • 0

I need to create a WCF service that is hosted in IIS, uses http transport and hold state in the server’s memory. While I’m aware that stateful services aren’t a good idea, this last constrain is necessary to make the service work with a legacy client.

My first thought was to asp.net’s session to store the values. I activated the asp.net compatibility mode in my service, which gave me access to the HttpContext, but values that were placed in the session object were not being persisted in memory. I assume this was because the http module that handles session state was not correctly configured, but when googling for answer I came across, WCF sessions and thought it might be a better idea to use them.

However, WCF sessions seem what under-document and place a strange set of prerequises on a service, and I haven’t been able to find a configuration that suits my needs: must be hosted in IIS, must use http or https transport and can’t reply on windows authentication because the client and server will not be part of the same domain. I’m trying to get this going using the wsHttpBinding, I had heard WCF sessions required either security or reliable message, but:
– Using the standard binding and when the servers are not part of the same domain it fails with a “SecurityNegotiationException The caller was not authenticated by the service” exception. This is fairly logical as it was using windows security.

  • If I disable security complete it fails with a “Contract requires Session, but Binding ‘WSHttpBinding’ doesn’t support it or isn’t configured properly to support it.”

  • If while keeping security disabled I enable reliable message I get the exception “Binding validation failed because the WSHttpBinding does not support reliable sessions over transport security (HTTPS). The channel factory or service host could not be opened. Use message security for secure reliable messaging over HTTP.”

  • I’ve tried enabling transport level security but this doesn’t seem to make any difference to the error generated

Is there any configuration that might work for me? Or should I just go back to the plan of using asp.net sessions?

  • 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-19T13:19:02+00:00Added an answer on May 19, 2026 at 1:19 pm

    You can have WCF hold session information in memory in a pretty simple way. To eliminate any possible external influences in my instructions, I’ll assume you’re starting with a brand new project:

    1. Create a new WCF Service Library project. This project will already contain a service with a WSHttpBiding binding preconfigured.
    2. Go to the service contract (IService1.cs) and change the ServiceContract attribute to the following:

      [ServiceContract(SessionMode = SessionMode.Required)]
      
    3. Go to the service implimentation (Service1.cs) and add the following ServiceBehavior attribute to the service class (Service1):

      [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Single)]
      
    4. Add session data as members of the service class (Service1):

      public class Service1 : IService1
      {
          ...
      
          private string UserFullName { get; set; }
      
          ...
      }
      
    5. Use the members to present session specific data (remember to also add them to the service contract, IService1):

      public class Service1 : IService1
      {
          ...
      
          public string Welcome(string fullName)
          {
              UserFullName = fullName ?? "Guest";
              return string.Format("Welcome back, {0}!", UserFullName);
          }
      
          public string Goodbye()
          {
              return string.Format("Come back soon, {0}!", UserFullName ?? "Guest");
          }
      
          ...
      }
      

    SessionMode.Required ensures that your clients are session-tracked.
    InstanceContextMode.PerSession ensures that an instance of your service class (Service1) is created for every session, so that you can retain session data in it and it will exist in memory across multiple calls in the same session.
    ConcurrencyMode.Single ensures that only one thread can enter each service class instance (Service1), and prevents possible concurrency issues if you only access data from the service class (and external thread-safe locations).

    EDIT: By default, WSHttpBinding only allows security sessions. But it also support reliable sessions, which allow establishing sessions without security enabled. The following binding configuration disables security and enables reliable sessions:

    <wsHttpBinding>
        <binding name="wsHttpBindingConfiguration">
            <security mode="None" />
            <reliableSession enabled="true" />
        </binding>
    </wsHttpBinding>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a backup of a SQL Server 2005 Database that's only
I have a WCF service which will be hosted under IIS. Now I have
I need to create an XML schema that looks something like this: <xs:element name=wrapperElement>
I need to create a linked server to a DB2 database on a mainframe.
I need to create a repeatable process for deploying SQL Server Reporting Services reports.
I need to create a button that has the same style as ButtonSpec with
I have a Web application and a WCF service hosted on the same Windows
I have a WCF service that is using a custom UsernamePasswordValidator. The validator needs
I have been working on a Silverlight app that consumes a WCF service. [on
I need to create a historical timeline starting from 1600's to the present day.

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.