locked
Session variable value lost in Chrome, but works fine in IE & FF! RRS feed

  • Question

  • User-1826411534 posted

    Hi, I've got this strange problem. I really don't know how to solve it, because it is so wired... I think may be the problem is in how the browser handles the ASP.net Cookie SessionID value.

    I'm using ASP.NET 3.5. Here's my code (I've isolated only the methods involved)

    public partial class Entrega : System.Web.UI.Page
    {
            protected List<EntregaDetalle> ListEntregaDetalle
            {
                get { return (List<EntregaDetalle>)Session["__LIST_ENTREGA_DETALLE__"]; }
                set { Session.Add("__LIST_ENTREGA_DETALLE__", value); }
            }
    
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    ListEntregaDetalle = new List<EntregaDetalle>();
                }
            }
    
            // THIS CODE HANDLES THE ITEM SELECTION FROM A GRID
            // THEN ADD TO THE LIST
            protected void gridStock_RowCommand(object sender, CommandEventArgs e)
            {
                if (e.CommandName == "Seleccionar")
                {
                    EntregaDetalle ed = new EntregaDetalle();
                    ed.IdStock = long.Parse(e.CommandArgument.ToString());
    
                    // HERE, IN CHROME ListEntregaDetalle.Count IS ALWAYS IN 0!
                    ListEntregaDetalle.Add(ed);
                    BindEntregaDetalle();
    
                    mvArticulos.SetActiveView(viewArticulos);
                }
            }
    
            private void BindEntregaDetalle()
            {
                gridEntrega.DataSource = ListEntregaDetalle;
                gridEntrega.DataBind();
            }
    }

    Does somebody had some similar problem?





    Thursday, April 29, 2010 7:30 AM

All replies

  • User533502567 posted

    Hi, I've got this strange problem. I really don't know how to solve it, because it is so wired... I think may be the problem is in how the browser handles the ASP.net Cookie SessionID value.
     

    By default Asp.Net session varible uses cookies to store session ID. Do you have cookies enabled in the Chrome?

    Thursday, April 29, 2010 9:59 AM
  • User-1826411534 posted

    Yes, the cookies are enabled. I navigate thrugh the cookies, and there it is, under localhost "ASP.NET_SessionId" and Expires when the browser closes...

    Thursday, April 29, 2010 12:16 PM
  • User-1826411534 posted

    Does somebody has a clue? :(

    Monday, May 17, 2010 7:38 AM
  • User1764777020 posted

    Did you ever find a solution to this problem?  I'm running into a very similar issue.

    Thanks!

    Tuesday, June 1, 2010 4:27 PM
  • User-1826411534 posted

    No man, unfortunately i didn't found a solution

    Sunday, June 6, 2010 6:37 PM
  • User1764777020 posted

    Hey, I eventually found a solution. The issue was with how I configured Apache (htaccess file) to do URL Rewriting to hide my front controller in the URL.  I'm not sure if this is relevant to you, since you are probably on IIS...

    Monday, June 7, 2010 12:08 AM
  • User-1826411534 posted

    Hi, well yes, I'm using IIS, but thanks, it may be useful. I'm lost, nobody had this problem?

    Wednesday, June 9, 2010 10:46 PM
  • User1113818664 posted

    i have a same problem... my application is working fine at FireFox and I E, but google chrome is lost some sessions data i don't know . y..

    please post the solution. i will thank ful to you

    Friday, May 27, 2011 7:50 AM
  • User1419007687 posted

    I just resolved this issue myself on IIS 7.5 2008 R2 .NET 4 (and 2). My scenario: 

    We operated a dedicated server, where we sell our service - www.domain1.com 

    We had a client that wished to mask his particular service to hisservice.domain2.com  

    domain2.com was hosted on his servers somewhere, which I never touched (it's his main website, which is wordpress I think-irrelevant). We simply configured redirects for hisservice.domain2.com to point to our server, and setup the host headers in IIS to receive this subdomain. 

    I cloned the application from domain1 (the main service) to the subdomain on domain2 and started receiving this very issue, ONLY on Chrome. I spent all day, only to read kavukattu 's response about URL ReWriting. I happen to be using MVC, and had the following route configured for whatever reason: 

    routes.MapRoute(
    "MainHome",
    "",
    new { controller = "Home", action = "Index" });

    I think I added this years ago testing something out, but it is essentially pointless, as the default route would do this anyways. Once I recompiled and deployed the Chrome issue completely went away. So from what kavukattu said, make sure you are checking your routes, as this applies in the IIS world as well. 

    Further, here's what my auth section looks like in web.config

    <authentication mode="Forms">
          <forms requireSSL="false" name="someuniquenameAuth" path="/" domain="hisservice.domain2.com" loginUrl="http://hisservice.domain2.com/Account/LogOn" timeout="2880" enableCrossAppRedirects="true"/>
        </authentication>

    Then inside the <system.web> element I added the following (which I don't think matters, since domain1 and domain2 are on different application pools, correct me if i'm wrong)

    <machineKey validationKey="get-a-key-from-link-below" decryptionKey="get-a-key-from-link-below" validation="SHA1" decryption="AES"/>

    The link I refer to generate your key is here: http://aspnetresources.com/tools/machineKey

    This worked very nicely for me. Hope this helps someone!

    Cheers. 


     

    Wednesday, September 26, 2012 5:21 PM
  • User398363945 posted

    I had this problem too! And it turned out that I didn't clear cache on chrome...cos i changed the session name and chrome still stores the original one.

    Sunday, July 12, 2015 11:47 PM