[CLOSED] Session management problem in IE8

  1. #1

    [CLOSED] Session management problem in IE8

    Hi,

    It appears that direct events are handled differently in IE8 and IE9 resulting in inconsistent session state. Please consider the code below. It works perfectly well for me in IE9. However, in IE8, the country selected is always empty until I refresh the SessionMain.aspx page using F5. What's the catch here? Please suggest a best practices approach or a workaround.

    Thanks,

    Vadym

    SessionMain.aspx
    <%@ Page Language="C#" %>
    
    <%@ Register TagPrefix="ext" Namespace="Ext.Net" Assembly="Ext.Net" %>
    <%@ Import Namespace="System.Linq" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Import Namespace="Ext.Net" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                string country = HttpContext.Current.Session["Country"] as string;
    
                if (!String.IsNullOrEmpty(country))
                {
                    this.ComboCountries.SelectedItem.Text = country;
                }
            }
        }
    
        protected void ComboCountries_Select(object sender, DirectEventArgs e)
        {
            string country = e.ExtraParams["Country"].ToString();
            HttpContext.Current.Session["Country"] = country;
            Ext.Net.Panel activeTab = X.GetCmp<Ext.Net.Panel>("Tab1");
    
            activeTab.Reload();
        }
    </script>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Panel runat="server" Frame="true" Height="120">
            <Items>
                <ext:ComboBox ID="ComboCountries" runat="server" Editable="false" Mode="Local" FieldLabel="Select country"
                    Width="260" SelectOnFocus="true" EmptyText="Select a country...">
                    <Items>
                        <ext:ListItem Text="Belgium" Value="BE" />
                        <ext:ListItem Text="Brazil" Value="BR" />
                        <ext:ListItem Text="Bulgaria" Value="BG" />
                        <ext:ListItem Text="Canada" Value="CA" />
                        <ext:ListItem Text="Chile" Value="CL" />
                        <ext:ListItem Text="Cyprus" Value="CY" />
                        <ext:ListItem Text="Finland" Value="FI" />
                        <ext:ListItem Text="France" Value="FR" />
                        <ext:ListItem Text="Germany" Value="DE" />
                        <ext:ListItem Text="Hungary" Value="HU" />
                        <ext:ListItem Text="Ireland" Value="IE" />
                        <ext:ListItem Text="Israel" Value="IL" />
                        <ext:ListItem Text="Italy" Value="IT" />
                        <ext:ListItem Text="Lithuania" Value="LT" />
                        <ext:ListItem Text="Mexico" Value="MX" />
                        <ext:ListItem Text="Netherlands" Value="NL" />
                        <ext:ListItem Text="New Zealand" Value="NZ" />
                        <ext:ListItem Text="Norway" Value="NO" />
                        <ext:ListItem Text="Pakistan" Value="PK" />
                        <ext:ListItem Text="Poland" Value="PL" />
                        <ext:ListItem Text="Romania" Value="RO" />
                        <ext:ListItem Text="Slovakia" Value="SK" />
                        <ext:ListItem Text="Slovenia" Value="SI" />
                        <ext:ListItem Text="Spain" Value="ES" />
                        <ext:ListItem Text="Sweden" Value="SE" />
                        <ext:ListItem Text="Switzerland" Value="CH" />
                        <ext:ListItem Text="United Kingdom" Value="GB" />
                    </Items>
                    <DirectEvents>
                        <Select OnEvent="ComboCountries_Select">
                            <EventMask ShowMask="true" />
                            <ExtraParams>
                                <ext:Parameter Name="Country" Value="item.getText()" Mode="Raw">
                                </ext:Parameter>
                            </ExtraParams>
                        </Select>
                    </DirectEvents>
                </ext:ComboBox>
            </Items>
        </ext:Panel>
        <ext:TabPanel ID="TabPanel1" runat="server">
            <Items>
                <ext:Panel runat="server" ID="Tab1" Title="Tab 1">
                    <AutoLoad Mode="IFrame" Url="~/SessionTab.aspx" ShowMask="true" />
                </ext:Panel>
            </Items>
        </ext:TabPanel>
        </form>
    </body>
    </html>
    SessionTab.aspx
    <%@ Page Language="C#" %>
    
    <%@ Register TagPrefix="ext" Namespace="Ext.Net" Assembly="Ext.Net" %>
    <%@ Import Namespace="System.Linq" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Import Namespace="Ext.Net" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                string country = HttpContext.Current.Session["Country"] as string;
    
                //X.Msg.Show(new MessageBoxConfig
                //{
                //    Title = "Status",
                //    Message = "Reloading tab :: " + country,
                //    Buttons = MessageBox.Button.OK,
                //    Icon = MessageBox.Icon.INFO,
                //    AnimEl = this.ClientID
                //});
                this.DisplayCountry.Text = country;
            }
        }
    
    </script>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Panel ID="Panel1" runat="server" Frame="true">
            <Items>
                <ext:DisplayField runat="server" ID="DisplayCountry" FieldLabel="You selected"></ext:DisplayField>
            </Items>
        </ext:Panel>
        </form>
    </body>
    </html>
    Last edited by Daniil; Jun 13, 2012 at 8:43 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I think it's related to the following discussions.
    http://stackoverflow.com/questions/3...ernet-explorer
    http://adamyoung.net/IE-Blocking-iFrame-Cookies

    You could try to apply the suggested solutions.

    Another approach could be sending the parameters in the load request.

    Parent Page
    protected void ComboCountries_Select(object sender, DirectEventArgs e)
    {
        string country = e.ExtraParams["Country"].ToString();
        Ext.Net.Panel activeTab = X.GetCmp<Ext.Net.Panel>("Tab1");
    
        activeTab.AutoLoad.Params.Add(new Ext.Net.Parameter("Country", country, ParameterMode.Value));
        activeTab.LoadContent();
    }
    Child Page
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!X.IsAjaxRequest)
        {
            this.DisplayCountry.Text = this.Request["Country"];
        }
    }
  3. #3
    Thanks Daniil,

    Has anyone ever had any luck with the suggested workaround to rectify the IFrame session cookie problems?

    HttpContext.Current.Response.AddHeader("p3p","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");
    This doesn't seem to work for me. I would be glad to get the session variables to work instead of passing them as request parameters since it's cleaner and more transparent. Unless there's absolutely no other choice, that is.

    Thanks,

    Vadym
  4. #4
    I have no pure IE8, tried under IETester and all works fine for me
    First ensure that the issue is related with cookie. Use Fiddler to check that cookies are passed to iframe page

    If problem is related with cookies then you can move session id to query string by adding the following instruction to web.config

    inside section '<system.web>'
    <sessionState mode="InProc" cookieless="UseUri" regenerateExpiredSessionId="true"/>
    extnet section
    <extnet cleanResourceUrl="false" />
  5. #5
    I've inspected the header and can see the Session cookie in the Request header for both pages:

    ASP.NET_SessionId=ksmjssy2oueiqd0a3qhmc3x2
    What could be the other options?

    Thanks,

    Vadym
  6. #6
    Please try to set NoCache="true" for AutoLoad to avoid possible caching. Does it help?
  7. #7
    Quote Originally Posted by Vladimir View Post
    Please try to set NoCache="true" for AutoLoad to avoid possible caching. Does it help?
    That was it!! It now works correctly in IE8, IE9 and FireFox 13. Should I use that NoCache="true" setting with any TabPanel, if so, what's the syntax when adding a tab dynamically on the client side? Are there any implications in setting this option to true?

    I have the following code on the client side. Setting noCache attribute to "true" doesn't seem to have any effect when a tab is reloaded on the client side.

                    tab = TabPanelMain.addTab({
                        id: id,
                        title: title,
                        iconCls: iconCls,
                        tabTip: tabTip,
                        closable: true,
                        doReload: false,    // Custom attribute
                        listeners: {
                            activate: {
                                fn: function () {
                                    if (this.doReload == true) {
                                        this.doReload = false;
                                        this.reload();
                                    }
                                }
                            }
                        },
                        autoLoad: {
                            showMask: true,
                            url: url,
                            mode: 'iframe',
                            noCache: true,
                            maskMsg: "Loading '" + title + "'...",
                            scripts: true
                        }
                    });
    Thanks,

    Vadym
  8. #8
    Quote Originally Posted by vadym.f View Post
    Should I use that NoCache="true" setting with any TabPanel
    Well, if you'd like to prevent caching, then yes.

    Quote Originally Posted by vadym.f View Post
    Are there any implications in setting this option to true?
    Apart from preventing caching, there should not be any implications.

    Quote Originally Posted by vadym.f View Post
    I have the following code on the client side. Setting noCache attribute to "true" doesn't seem to have any effect when a tab is reloaded on the client side.
    Should be all lower-case.
    nocache : true
  9. #9
    Thanks a lot for all the suggestions, setting NoCache on the server and nocache on the client to "true" got the session problem resolved without touching P3P response headers.

    Vadym
  10. #10
    Yes, it has appeared to be just a cache issue, not a Session one.

Similar Threads

  1. Session problem on IIS7
    By ven in forum 1.x Help
    Replies: 5
    Last Post: Jun 24, 2011, 3:33 PM
  2. Replies: 2
    Last Post: Feb 05, 2010, 5:20 PM
  3. Concerned about memory management
    By dbassett74 in forum 1.x Help
    Replies: 3
    Last Post: Nov 16, 2009, 4:33 PM
  4. Print job management for web applications
    By Nime in forum Open Discussions
    Replies: 1
    Last Post: Aug 04, 2009, 10:12 AM
  5. [CLOSED] Page_Load bug and session state management
    By jsemple in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 24, 2009, 5:30 PM

Tags for this Thread

Posting Permissions