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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:40:36+00:00 2026-06-11T16:40:36+00:00

We are currently working on a multi-tenant application that is running into some random

  • 0

We are currently working on a multi-tenant application that is running into some random strange behavior in relation to how it deals with the multi-tenancy aspect.

Background: We have an ASP.NET application that is to be used by multiple groups of end users. The URL that they use to access the application determines which company they are associated with and eventually their database connection string. We store a static list of CompanyHost mappings that map the specific Company ID to host name. If we don’t find a match in the static list we re-pull the list from the database.

When the application first starts up it correctly pulls up the connection finding the correct Company ID for a host. However, after an unknown period of time the application will start returning an empty ID for all host headers, even if they exist inside of the database causing the application to be unable to determine the connection string. Going onto the server and recycling the application pool resolves the issue. I have attempted to set the Application Pool recycle time to something low (2 hours) to try and avoid it however it is either not low enough or is not the problem.

Here is the snippet that gets the company ID by host. This is returning an Empty Guid even for a valid host name.

private static List<CompanyHost> lCompanyHosts = new List<CompanyHost>();

public static string Host
{
    get { return HttpContext.Current.Request.Url.DnsSafeHost; }
}

public static Guid CompanyIDByHost
{
    get
    {
        Guid gCompany_ID = Guid.Empty;

        lock (lCompanyHosts)
        {
            if (lCompanyHosts.Count == 0)
                lCompanyHosts = new CompanyHostDataLogic().RetrieveAll();

            gCompany_ID = lCompanyHosts.Where(ch => ch.hostname.ToLower() == Host.ToLower()).Select(ch => ch.company_id).FirstOrDefault();

            if (gCompany_ID == Guid.Empty)
            {
                lCompanyHosts = new CompanyHostDataLogic().RetrieveAll();
                gCompany_ID = lCompanyHosts.Where(ch => ch.hostname.ToLower() == Host.ToLower()).Select(ch => ch.company_id).FirstOrDefault();
            }
        }

        return gCompany_ID;
    }
}

I am having a hard time understanding why this would be returning Guid Empty for valid hosts after a period of time where it is working normally. My best guess is it has something to do with a period of inactivity on the website that is causing the issue. I am however unsure of the best way to resolve this.

Is there something I am missing or would there be a better way to implement this type of functionality?

  • 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-11T16:40:38+00:00Added an answer on June 11, 2026 at 4:40 pm

    What ended up being the problem and the ultimate answer to my solution here is that this process was firing on application pool start up. Prior to there being an actual request so the host name that was being used as a key was null.

    This caused the strange behavior the errors that we were seeing.

    After changing the initial load to a static object and then adding the dynamic load in as a lazy load it resolved the issue.

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

Sidebar

Related Questions

I'm currently working on a multi-tenant application that employs Shared DB/Shared Schema approach. IOW,
I'm currently working on a SaaS type application, and for multi-tenancy I've settled on
I have a multi-threaded Delphi 6 Pro application that I am currently working on
I'm working on a multi-threaded C# Windows application that makes frequent calls into a
I am currently working on a multi window application that spans over multiple screens.
I'm currently working on a multi-threaded application that would be deployed on arm and
I'm currently working through an assignment that deals with Big-O and running times. I
I'm currently working on a multi-threaded application, and I occasionally receive a concurrently modification
Im currently working on a game that uses multi touch to apply zoom to
Currently working with converting SQLException error messages into messages that are more useful for

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.