Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have strange problem.
I initialize some values in session after click on selected row in grid view.
it is working fine.

But when two or more users (* All have different machines and different user) click on different rows of grid view than values of all session will assign to other users.
for example if usser1 and user2 click on gridview on same time than all sessions of user1 will assign to user2 that mean user2 now have all credentials of user1.

but when i added thread.sleep(500) just before the initialization of session than it is working fine.

can anyone enlighten me the problem how i can stop sharing of sessions?

Sample code for better understanding :

1)
Class:-

namespace ABC.ZXY
{
    [Serializable]
    public class Employee
    {
        public Employee();
        public Employee(EntAhsviresourcesRow row);
        public Employee(EntEgemAhsresourcesRow row);
        public AgressoAddress Address { get; set; }
        public string AparGrId { get; set; }
     }
}


2)
Grid View event "SelectedIndexChanging"

protected void grvEmployeeSearch_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
   Employee resource = (Employee)grvEmployeeSearch.DataKeys[e.NewSelectedIndex].Value;
 	
	if (resource != null)
            {
                resource = ec.GetEmployeePositionsByEmployee(resource, Client);
                SelectedResource = resource;
                Session["Resource"] = resource;
		Response.Redirect("Resource.aspx");
            }
.
.
.
}

3)
On resource.aspx page:

Employee ResourceFromSearch
protected void Page_Load(object sender, EventArgs e)
        {
		ResourceFromSearch = (Employee)Session["Resource"];
	}


Now on Resource.aspx we got invalid session.( Not only this session but all sessions)

Regards
Posted
Updated 27-Jun-11 8:00am
v5
Comments
Karthik. A 27-Jun-11 12:32pm    
edit - added pre tags for code blocks
BobJanova 28-Jun-11 8:35am    
Please show where you initialise the session, and where the sleep statement goes. As Pete says (and you suggested yourself) Session is supposed to be unique so this is a strange one.

As you are aware, a Session value is supposed to be unique to the user session, so unless something is completely screwed up with the IIS setup, it has to be something to do with the way you are managing the Session. Unfortunately, you forgot to post any of your code for actually adding the information to the session, so I can't take a look at it for you to see if there's anything obvious.
 
Share this answer
 
Comments
mahesh__kumar__sharma 27-Jun-11 12:15pm    
Hi,
Thanks for helping me. I improved my question for better understanding, please have a look on this.
Take a look a the following article, it explains how session is handled. I do not think session does overlap. Most possibly, it could be the cache in your application.

Session State Providers[^]

If this is not the case. Can you pleae add more details to your question.

Note: If you are implementing a custom session provider this may not be applicable.
 
Share this answer
 
Comments
mahesh__kumar__sharma 27-Jun-11 12:29pm    
No we have no cache in our application and it works fine if user hit gridview's row wiht interval of 1 or more second.

Even if i add thread.spleep it workes fine.
Instead of sharing session values could you use application object to share / exchange information between two or more users
 
Share this answer
 
Comments
mahesh__kumar__sharma 27-Jun-11 11:51am    
my problem is stop this sharing. and queries to know why sleep(500) remove this problem.

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