开发者

MVC.net session gets mixed between users

I am storing user objects in session, pulling them out in the controllers, and sometimes write some data into them. but when to users post at the same time, the sessions get mixed fro some reason.

Does anyone have any idea how that is possible ?

typical post:

  [HttpPost]
    public ActionResult Index(QuestionModel model, FormCollection collection)
    {
        var person = ((Person)Session["Person"]);
        if (!ModelState.IsValid)
        {
            ModelState.Clear();
            ModelState.AddModelError("", Global.Global.error);
            return View(new QuestionModel(person.page, (CultureInfo)Session["culture"]));
        }
        person.page = model.Page;
        while (person.Answers.Count > model.Page - 1)
        {
            person.Answers.RemoveAt(person.Answers.Count - 1);
        }
        var answer = new Answer() { answer = model.ChosenAnswer, Question = "Q" + person.page };
        person.Answers.Add(answer);
        if (!CheckForNextPage(person.page开发者_JS百科)) { person.hasFinishedQuestions = true; return RedirectToRoute("Result"); }
        person.page++;
        return View(new QuestionModel(person.page, (CultureInfo)Session["culture"]));
    }

I echo the session id on every page, and when a couple of users are using the website they get each others session + sessionid ...

@update: 3 experienced developers have been looking for the problem for 2 days, still no solution. already removed about 95% off the code, still same issue. server posts back responses from another session


This is not possible. So this is my guess: You are testing this wrongly, you are using different tabs from the same browser. Some people don't know that this doesn't create a different session.

Try testing this on 2 different browsers (i.e. firefox and chrome) as they will not share the session (as the session id is normally stored in a cookie).

Please report back if this was the case.


We "solved" it. We didn't actually solve it, but we copied all the sources to a new project, recompiled, and everything worked. Untill this day, we still don't know why, and how that error happened ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜