Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have an application written in ASP.NET 3.5, where users are stored in the database and their user roles for authentication and authorization process to the system.

The problem occurs when I deploy the application to the server and at one time when multiple users log in, the logged-in user switches to the other last logged-in user spontaneously.
So I can see the switching users durign the crossing between pages..

Does anyone know what to do/set/focus in Google..??

Thank you very much for any advice.

Jan

What I have tried:

Hello,

I have an application written in ASP.NET 3.5, where users are stored in the database and their user roles for authentication and authorization process to the system.

The problem occurs when I deploy the application to the server and at one time when multiple users log in, the logged-in user switches to the other last logged-in user spontaneously.
So I can see the switching users durign the crossing between pages..

Does anyone know what to do/set/focus in Google..??

Thank you very much for any advice.

Jan
Posted
Updated 23-Jun-19 22:05pm

1 solution

It's impossible to say without seeing the code. My guess is that you're probably using static variables, so start by looking for those. Static variables are shared across all users.
 
Share this answer
 
Comments
MitchCZ 24-Jun-19 5:05am    
Uff, you are right! :) it looks like on a absolutly bad solution...

main Login.aspx:
protected void LoginMain_LoggedIn(object sender, EventArgs e)
{
GlobalSettings gSet = new GlobalSettings(LoginMain.UserName.ToString());
}

Constructor of GlobalSettings:
public GlobalSettings(string uName)
{
UserName = uName;
User_Name = GetNameLogged();
UserDepartmentNo = GetDepartmentNoLogged();
UserRole = GetUserRole();
IdOrder = 0;
IdOrderURL = 0;
IdOrderQString = 0;
OrderState = 1;
OrderWorking = false;
OrderJustReleased = false;
AHUCount = 0;
UserTrade = IsUserRoleTRADE(UserName);
UserOdbyt = IsUserRoleODBYT(UserName);
UserOdbytDep = IsUserRoleODBYTDEP(UserName);
UserRoleMain = SetUserRole(UserName);
}

Private variables:
private static string userName;
public static string UserName
{
get { return userName; }
set { userName = value; }
}

private static string user_Name;
public static string User_Name
{
get { return user_Name; }
set { user_Name = value; }
}

private static string userRole;
public static string UserRole
{
get { return userRole; }
set { userRole = value; }
}
...

What now?
F-ES Sitecore 24-Jun-19 6:13am    
It depends on how you are authenticating people really. The simplest solution is to store that data in the Session instead, so Session["userName"] for the username etc, or create a User object that has all the data you want to remember about a user and store that object in the Session instead.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900