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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:17:01+00:00 2026-05-30T11:17:01+00:00

In an environment where about 100+ users are logging on to a site with

  • 0

In an environment where about 100+ users are logging on to a site with
forms authentication, calling HttpContext.Current.User.Identity.Name
returns the correctly logged on user.

However, 10% of the time the wrong user Full Name info is being returned.
I never had such problem on my testing machine it happens only in production. I cannot recreate the same environment with many users on my test machine.

The logic of this app:

1) User enters username and pass, info is looked up via SQL DB call, if match, user is authenticated via
FormsAuthentication.RedirectFromLoginPage(username, false)

 FormsAuthentication.SetAuthCookie(user.SYS_Users_ID.ToString(), false);

 if (Request["ReturnURL"] == null)
    FormsAuthentication.RedirectFromLoginPage(user.SYS_Users_ID.ToString(), false);
 else
     Response.Redirect("/" + SysConfig.ApplicationName + appConfig.DefaultPages.DefaultPage);

2)After redirect I put the user full Name into hidden field

if (!IsPostBack)
     userFullName.Value = Helper.GetCurrentUserFullName();

...

public static string GetCurrentUserFullName()
{
    string _userFullName = string.Empty; 
    try
    {
        _userFullName = new AgrotMasofim.DAL.Users.Users().GetUserFullName(GetCurrentUserID());
    }
    catch (Exception ex)
    {
        Logs.WriteToFileLog(string.Empty,ex);
    }
    return _userFullName;
 }



public static Decimal GetCurrentUserID()
        {
            Decimal _userID = 0;

            if (HttpContext.Current.User != null)
            {
                try
                {
                    _userID = Convert.ToDecimal(HttpContext.Current.User.Identity.Name);
                }
                catch (Exception ex)
                {
                   Logs.WriteToFileLog(string.Empty, ex);
                }
            }
            return _userID;
        }

3) On all the pages the user visits, his/her info is shown inside Label that is on master page

  lblUserName.Text = HttpUtility.HtmlDecode("Hello " + userFullName.Value);

This works almost all the time. Any ideas why it might be failing from
time to time?

  • 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-30T11:17:03+00:00Added an answer on May 30, 2026 at 11:17 am

    Absent more code, I can only guess at your problem. Since other people may find your question and have similar problems, I’ll guess that your problem lies in a faulty use of static classes or properties.

    Your GetCurrentUserFullName() method could rely on a data access method that is statically shared between all threads. There could be a race condition in the data access class(es) which sometimes results in the id of the user being searched for being replaced with that from another request before the data is retrieved. The solution to this is to either (a) use locks in all critical sections of your data access class(es) or (b) use a solution that instantiates a new data access class(es) for each request (really each unit of work). The latter design requires that your data access class(es) be lightweight, but would be preferable as it will be easier to test as well.

    It’s also possible, if you are caching values in static properties or other static classes that would be shared between threads, that you have a similar race condition where those values are cached and used. Similar solutions would apply – using locking or use per-thread instances rather than static instances.

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

Sidebar

Related Questions

I've read the help of eclipse in blackberry development environment about the auto run
We are in the process of setting up a new development environment for about
First a bit about the environment: We use a program called Clearview to manage
I would like a web application to learn things about its environment so that
When reading about pipes in Advanced Programming in the UNIX Environment, I noticed that
I'm wondering about the downsides of each servers in respect to a production environment.
I've been thinking about batch reads and writes in a RESTful environment, and I
I'm curious about the various versions of .net. We have an environment where we've
I've always wondered about this ... and thankfully, now have a good environment of
The SCons User Guide tells about the usage of Multiple Construction Environments to build

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.