loosing a session value - DOTNET
This is a discussion on loosing a session value - DOTNET ; 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 ...
-
loosing a session value
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
-
Re: loosing a session value
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" <aftab.pucit@gmail.com> wrote in message
news:095dd17f-1e98-40e5-9800-e71cdd12d548@y33g2000prg.googlegroups.com...
> 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
-
Re: loosing a session value
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
-
Re: loosing a session value
On Apr 3, 10:18 pm, CreativeMind <aftab.pu...@gmail.com> 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..