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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:27:54+00:00 2026-06-05T08:27:54+00:00

I have a WCF service configured to use ASP.NET session state. I have tested

  • 0

I have a WCF service configured to use ASP.NET session state. I have tested this WCF service with a WPF client and the session state is maintained across the different web requests.

Now I am trying to use this same WCF service from a Silverlight app which uses the new Http stack independent from the browser. I need to use this stack in order to be able to understand our WCF service faults. My problem is that in this case we are not able to read from the responses the Set-Cookie header with the ASP.NET_SessionId cookie or set the Cookie header in the requests.

This is the binding from the Silverligth application:

  <customBinding>
    <binding name="customHttpBinding_IBasoaWebService" sendTimeout="01:00:00">
            <binaryMessageEncoding />
      <httpCookieContainer />
            <httpTransport maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
    </binding>
  </customBinding>

And this is the binding of the WCF service:

  <basicHttpBinding>
    <binding name="basicHTTP" closeTimeout="01:00:00" openTimeout="01:00:00"
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
        receiveTimeout="01:00:00" sendTimeout="01:00:00" allowCookies="false">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
        maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="None" />
    </binding>
  </basicHttpBinding>

In the Silverlight application we are using this code to read the Set-Cookie header in the response:

            IHttpCookieContainerManager cookieManager = channel.GetProperty<IHttpCookieContainerManager>();
            if (cookieManager.CookieContainer == null)
                cookieManager.CookieContainer = new CookieContainer();
            Uri applicationUri = new Uri(Application.Current.Host.Source, "../");
            string cookieString = cookieManager.CookieContainer.GetCookieHeader(applicationUri);
            ParseCookieString(cookieString);

And this is the code to set the ASP.NET Session ID cookie in the request:

            IHttpCookieContainerManager cookieManager = channel.GetProperty<IHttpCookieContainerManager>();
            if (cookieManager.CookieContainer == null)
                cookieManager.CookieContainer = new CookieContainer();
            Uri applicationUri = new Uri(Application.Current.Host.Source, "../");
            Cookie cookie = new Cookie("ASP.NET_SessionId", aspNetSessionId);
            cookieManager.CookieContainer.Add(applicationUri, cookie);

Checking through Fiddler the messages which are exchanged I see that the WCF service sends correctly the Set-Cookie header in the first response, but the Silverlight is not able to read it. I have also tried to set the Cookie header in the request through the CookieContainer class, but with no luck. I cannot see it in Fiddler.

Coould someone give me an advice about what I must be doing wrong?

Many thanks in advance.

Jose Antonio Arroba

  • 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-06-05T08:27:56+00:00Added an answer on June 5, 2026 at 8:27 am

    Finally I have been able to find a workaround to solve this problem.

    The reason why the Cookie header was not sent with the requests was that I was setting a bad Uri in the Cookie object. If I am trying to connect to http://localhost:8080/Service, it seems taht the correct Uri value to provide is http://localhost:8080 and not http://localhost:8080/Service.

    However I am still wondering how to read the Set-Cookie sent by the server. My workaround consist on sending the ASP.NET Session ID also in a custom SOAP header and read it in the client, which is IMHO rather redundant. But it works.

    • 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 that I need to call in a ASP.NET web
I have WCF service and Silverlight Client. I use PollingDuplexElement. On server side I
I have an ASP.NET MVC web app whose controllers use WCF to call into
I have a WCF service configured to use custom UserName validation via the overridden
I have an IIS-hosted WCF service which is configured to use basicHttpBinding with transport
I have a wcf service defined like this: [OperationContract] [WebInvoke(Method = POST, ResponseFormat =
We have a .NET 3.5 Web Service ( not WCF) running under IIS. It
I need to host a WCF Data service as part of a legacy ASP.NET
I have a WCF service and a client, that uses a custom UserNamePasswordValidator for
I am trying to configure my WCF Service to be HTTPS. I have configured

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.