开发者

Stange issue with session

I have something strange going on with our session state. Our AS开发者_C百科P.NET C# application has a session timeout of 10 min, but it seems to be losing session state when redirecting between pages.

So, we set out session value, and redirect to the next step,

        Session["temp"] = "somevalue";
        Response.Redirect("page2.aspx");

At the top of page2, we check the session value, and if it's not there, redirect back to the start (the code below is the first on Page_Load):

        if (Session["temp"] == null)
        {
            Response.Redirect("start.aspx");
        }

The issue is it keeps on doing this redirect, even though the session should not have timed out.

I have checked the config file, and it has a machinekey, as I have been informed that this can sometimes causes issues if it's not there.

Is there something else that could be causing us to lose the session?


Depending how your session's configured, cookie problems can cause you to lose session. As can switching domains / switching between http and https.

And as an aside, if you're connecting over a mobile connection, all sorts of horrible things can happen to your cookies...


Disabled Coockies may be issue. You can also create brand new application (with default web.config without any change) with single page and test it. This will tell you whether the problem is application specific or server specific.


try to add to system.webServer -> modules section in web.config next lines:

<remove name="Session" />
<add name="Session" type="System.Web.SessionState.SessionStateModule" />
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜