loosing a session value

  • Thread starter Thread starter CreativeMind
  • Start date Start date
C

CreativeMind

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
 
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.
 
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
 
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..
 
Back
Top