loosing a session value

Discussion in 'ASP .Net' started by CreativeMind, Apr 2, 2009.

  1. CreativeMind

    CreativeMind Guest

    hi all,

    i used a master page, i m checking wether session["usertypeid"] is
    null or not (on usertypeid base, i m changing menu) but after 6-7
    minutes, i get null value.. other session value retain. can u give me
    any info,
    thx
     
    CreativeMind, Apr 2, 2009
    #1
    1. Advertising

  2. CreativeMind

    sloan Guest

    The best thing to do is to encapsulate the call to set and to read the
    value.


    public static class SessionHelper

    {

    private static readonly string USERTYPEID = "usertypeid";

    public static int GetUserTypeID(Page p)
    {
    int returnValue = 0;
    if (null!= p.Session[USERTYPEID] ) //<<no quotes, use the
    readonly static variable
    {
    returnValue = Convert.ToInt32( p.Session[USERTYPEID] );
    }
    return returnValue;
    }

    public static void SetUserTypeID(Page p , int value)
    {
    p.Session[USERTYPEID] = value;//<<no quotes, use the readonly static
    variable
    }

    }



    This way you can set a break point to know who is setting it and who is
    reading it.


    My guess is that you have a rouge setter.







    "CreativeMind" <> wrote in message
    news:...
    > hi all,
    >
    > i used a master page, i m checking wether session["usertypeid"] is
    > null or not (on usertypeid base, i m changing menu) but after 6-7
    > minutes, i get null value.. other session value retain. can u give me
    > any info,
    > thx
     
    sloan, Apr 2, 2009
    #2
    1. Advertising

  3. CreativeMind

    CreativeMind Guest

    i set configurations in web.config as

    <authentication mode="Forms">
    <forms name="cokks" loginUrl="admin/default.aspx" protection="All">
    </forms>
    </authentication>

    ------------

    and codebehind default.aspx.cs

    private void btnGo_Click(object sender,
    System.Web.UI.ImageClickEventArgs e)
    {

    Response.Redirect("Properties.aspx", false);

    }

    ----------------

    private void Page_Load(object sender, System.EventArgs e)
    {

    masterData = new MasterDL();

    if(!IsPostBack)
    {

    Session.RemoveAll();
    }
    }

    ---------------------

    before changes in config file, it was successfully running, but now i
    m unable to redirect . instead of redirecting , it again and again
    calls page_load method changing the url as default.aspx?returnurl=
    %2fadmin%2fProperties.aspx

    and opens the same page, why isn't it redirecting? if i debug, i see
    redirectlocaton='admin/properties.aspx' but then it calls default.aspx
    again.. can u guide me please? thanx
     
    CreativeMind, Apr 3, 2009
    #3
  4. CreativeMind

    CreativeMind Guest

    On Apr 3, 10:18 pm, CreativeMind <> wrote:
    > i set configurations in web.config as
    >
    > <authentication mode="Forms">
    >  <forms name="cokks" loginUrl="admin/default.aspx" protection="All">
    >  </forms>
    > </authentication>
    >
    > ------------
    >
    > and codebehind default.aspx.cs
    >
    > private void btnGo_Click(object sender,
    > System.Web.UI.ImageClickEventArgs e)
    >         {
    >
    >             Response.Redirect("Properties.aspx", false);
    >
    >         }
    >
    > ----------------
    >
    > private void Page_Load(object sender, System.EventArgs e)
    >         {
    >
    >             masterData = new MasterDL();
    >
    >             if(!IsPostBack)
    >             {
    >
    >                 Session.RemoveAll();
    >             }
    >         }
    >
    >  ---------------------
    >
    > before changes in config file, it was successfully running, but now i
    > m unable to redirect . instead of redirecting , it again and again
    > calls page_load method changing the url as default.aspx?returnurl=
    > %2fadmin%2fProperties.aspx
    >
    > and opens the same page, why isn't it redirecting? if i debug, i see
    > redirectlocaton='admin/properties.aspx' but then it calls default.aspx
    > again.. can u guide me please? thanx


    In case of server.transfer("properties.aspx"), it accessess
    properties.aspx page, but i don't want to use server.transfer koz i've
    to show url in the browser..
     
    CreativeMind, Apr 3, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jonk Eidersteldvr

    Session Variables - Loosing

    Jonk Eidersteldvr, Aug 29, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    537
    Mark MacRae
    Aug 29, 2003
  2. Radu Colceriu

    Loosing session variables

    Radu Colceriu, Jan 16, 2004, in forum: ASP .Net
    Replies:
    8
    Views:
    701
    Hermit Dave
    Jan 16, 2004
  3. =?Utf-8?B?V2luZGphbW1lcg==?=

    Loosing Session values across Applications

    =?Utf-8?B?V2luZGphbW1lcg==?=, Feb 17, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    398
    =?Utf-8?B?QW51cmFkaGE=?=
    Feb 17, 2004
  4. Robert Berezka

    Loosing Session Variable in ASP.NET

    Robert Berezka, Feb 25, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    4,350
    Fred Nelson
    Feb 25, 2004
  5. Patrick

    ASP.NET - Loosing Session Variables

    Patrick, Aug 3, 2004, in forum: ASP .Net
    Replies:
    9
    Views:
    3,299
    Patrick
    Aug 12, 2004
Loading...

Share This Page