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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:48:12+00:00 2026-05-16T01:48:12+00:00

I have a very subtle bug that I’m having trouble identifying. Background: We have

  • 0

I have a very subtle bug that I’m having trouble identifying.

Background:
We have 2 sites running off the same application on the same web server.

  • SiteA — accessed by http://www.SiteA.com
  • SiteB — accessed by http://www.SiteB.com

When the request first comes in, the siteId is identified based on the Host and stored in the Session as follows:

protected void Application_BeginRequest(object sender, EventArgs e)
{
    string host = Request.Url.Host;
    int siteId = new SiteManager().GetSiteByUrl(host).SiteId;
    if (SessionUser.Instance().SiteId != siteId)
    {
        SessionUser.Instance().SiteId = siteId;
    }
}

This ID used later in determining what data to retreive and to determine what style to present:

 // this happens during an initialization phase
 _siteConfiguration = _siteManager.GetSiteById(SessionUser.Instance().SiteId);

// then later:
private void SetPageTheme()
{
    string theme = null;

    switch (_siteConfiguration.SiteId)
    {
        case ConfigurationHelper.SITE.A:
            theme = "SiteATheme";
            break;
        case ConfigurationHelper.SITE.B:
            theme = "SiteBTheme";
            break;                
    }

    Page.Theme = theme;
}

The problem:

the problem I’m facing is if you load both sites at almost exactly the same time, i.e. within milliseconds, sometimes SiteA will load with SiteB’s theme and vice versa. This doesn’t happen very often but it has come to the attention of the client so it’s now a problem.. Something is happening somewhere within those few milliseconds in the difference between SiteA loading and SiteB loading, and I don’t know how to identify what that is.

The question:

Does anyone have any ideas what could be going wrong here? Something is getting confused somewhere. Is it IIS mixing up the requests? Is it the Session mixing up the site it’s supposed to return the SiteId for?

If any more info is needed, I’ll supply it.

Update:

For reference, this is the definition of SessionUser (basically, create a static instance of an object to get the SiteId value from the Session):

public class SessionUser
{
    private static SessionUser _instance;


    public int SiteId { get; set; }


    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    public static SessionUser Instance()
    {
        if (null == _instance)
        {
            _instance = new SessionUser();

            if (null != HttpContext.Current.Session)
            {
                if (null == HttpContext.Current.Session["User"])
                {
                    if (HttpContext.Current.Request.QueryString["sid"] != null)
                    {
                        int nSiteId = int.Parse(HttpContext.Current.Request.QueryString["sid"]);
                        _instance.SiteId = nSiteId;

                        HttpContext.Current.Session["User"] = _instance;

                    }
                }
                else
                {
                    _instance = (SessionUser) HttpContext.Current.Session["User"];
                }
            }
        }

        return _instance;
    }
}
  • 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-16T01:48:13+00:00Added an answer on May 16, 2026 at 1:48 am

    Without knowing what the ‘SessionUser’ class looks like, I can only speculate.

    I will assume that SessionUser.Instance() returns a ‘static’ instance (or member rather).

    Now, these will be shared across the entire application. So it makes sense that this cannot be shared between 2 sites.

    I suggest you rather use HttpContext to store the setting at BeginRequest.

    The code will then look like the following:

    class SessionUser
    {
      public static SessionUser Instance()
      {
        var ctx = HttpContext.Current;
        var su = ctx["SessionUser"] as SessionUser;
        if (su == null)
        {
          ctx["SessionUser"] = su = new SessionUser();
        }
        return su;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.