Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
 After login to MVC application initializing data using below statements and All are static variables. Data coming from DB if the login is successful.
iRISConstants.UserID = row["UserID"].ToString();
iRISConstants.SessionID = row["SessionID"].ToString();

Maintaining this data in static variables since after user login if he do any transaction i have to pass UserID and SessionID to SP call
Here is the problem when hosted the application on IIS server.
1. User login from one machine and variable are initialized.
2. Another user log in to machine and variable get override.
The user id is updated and whatever the transaction do from both first user or second user sending second userID and sessionID since the static data assigned with second logged in user details.
What is the way to resolve it

What I have tried:

<pre>i tried sessions.
1.When one user login i store first user in session variable 
2.When other user log in store second user in different session varible
Lets say both(Different) user logged in some user did transaction i want to send that particular user UserID and SessionID to SP call 
Is there any way to know which user is doing transaction because we are getting only user information during user login, later i have maintain it from application as SP required those 2 parameter
Posted
Updated 4-Apr-18 6:29am

1 solution

There is only one instance of a static variable that everyone shares so it's not suitable for storing this data. You need to store your data in the Session instead as that is intended for this very purpose. If you're having problems using the Session then post the relevant code and explain the issue.
 
Share this answer
 
Comments
Member 11042699 5-Apr-18 3:33am    
Below are set of statements i have tried.
Session["UserID"] = row["UserID"].ToString();
Session["SessionID"]= row["SessionID"].ToString();

Stored in session but when other user login to system the value get override. Still the user who logged in first with UserID and SessionID those information i need since i am passing those values to SP. By that time value overrided the second user UserID and SessionID so session also i cannot store
F-ES Sitecore 5-Apr-18 4:34am    
is the other person logging in on the same browser on the same machine?
Member 11042699 5-Apr-18 9:02am    
no different machine different browser
F-ES Sitecore 5-Apr-18 9:49am    
There's something about your code\set-up you're not telling us as that is not how sessions work.

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