locked
Session variable being lost between pages RRS feed

  • Question

  • User925837561 posted

    Hi.  I wonder if someone can point me in the right direction please.  In my asp.net application I store a session variable using Session.Add("MyVariable","MyVariableValue") and then send the user to another page using Respone.Redirect("~/mypage.aspx",False).  In the Page_Load of mypage.aspx I then assign this variable to a local object variable using objMyVariable=Session.Item("MyVariable").  On my dev machine this works fine but on the production IIS server it does not.  Essentially Session.Item("MyVariable") is Nothing.

    Things I have tried are:-

    I have added EnableSessionState="True" to the page declarations.

    I have added <sessionState mode="InProc" cookieless="false" timeout="20"></sessionState> to my web.config

    Strangely, if I browse my page directly from the content view in IIS Manager, the whole thing works perfectly.  However if I browse the page from Internet Explorer on the same machine with the same user login, it does not.  Can anyone suggest what I might look at in order to correct this problem?

    Many thanks in advance.

     

    UPDATE

    I have just realised that the session variable is not lost when using Chrome or Firefox, purely Internet Explorer.  Hopefully this will tell someone far cleverer than me exactly what the problem is.

    Thursday, January 31, 2013 4:19 PM

Answers

  • User925837561 posted

    Got it.  The host name of the machine this is running on contains an underscore.  Two days, two bloody days!!!  Hope this helps someone else.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 31, 2013 5:03 PM