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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:16:05+00:00 2026-05-31T12:16:05+00:00

The code sample at http://support.microsoft.com/kb/2527105 is exactly what I need to share sessions between

  • 0

The code sample at http://support.microsoft.com/kb/2527105 is exactly what I need to share sessions between two subdomains. Only problem is it doesn’t work in a real life situation. It works fine when the ony file being requested is the page itself, but throws an error ‘session state is not available in this context’ when other files are part of the request, such as if I add stylesheets or javascript files to the page. The code is generating this error in the “if (context.Session != null &&” line below:

void context_PostRequestHandlerExecute(object sender, EventArgs e)
{
    HttpApplication context = (HttpApplication)sender;
    HttpCookie cookie = context.Response.Cookies["ASP.NET_SessionId"];

    if (context.Session != null &&
        !string.IsNullOrEmpty(context.Session.SessionID))
    {
        cookie.Value = context.Session.SessionID;
        if (rootDomain != "localhost")
        {
            cookie.Domain = rootDomain;
        }
        cookie.Path = "/";
    }
}
  • 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-31T12:16:06+00:00Added an answer on May 31, 2026 at 12:16 pm

    You can try a Try Catch Block, then you can trap for a null value.

        private HttpSessionState GetSession(HttpApplication context)
        {
            try
            {
                //On Abadon or Logout this returns "Session state is not available in this context. "
                return context.Session;
            }
            catch (HttpException)
            {
                return null;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got some sample code from the net here: http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class That works fine. It
According to http://support.microsoft.com/kb/288902/en-us You can attach to a specific instance if you know the
I use this code: http://blogswizards.com/plugin-development/sliding-boxes-and-captions-with-jquery On a simple gallery site I am building. Specifically
I am looking into authenticating via google. I dont understand how it works: http://code.google.com/apis/accounts/docs/OpenID.html#Samples
according to here: http://watwp.codeplex.com/wikipage?title=Architecture%20Diagrams The SQL Azure OData Service is a sample WCF Data
I want ot get response for the google checkout .I have used http://code.google.com/apis/checkout/samples/Google_Checkout_Sample_Code_PHP_CheckoutShoppingCartDemo.html#googleCheckoutFunctionDisplayDiagnoseResponse The
You can find the source code demonstrating this issue @ http://code.google.com/p/contactsctp5/ I have three
I've used a thread managed waiter. SyncLock http://msdn.microsoft.com/en-us/library/3a86s51t%28v=vs.71%29.aspx But now, I wanted to have
I found a code samples here: http://sturla.simnet.is/post/2008/09/22/Enable-proxy-in-IE.aspx But it's very complex and involves manipulating
I would like a code sample for a function that takes a tDateTime and

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.