loosing a session value

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
 
S

sloan

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.
 
C

CreativeMind

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
 
C

CreativeMind

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top