Accessing cookies in base class

  • Thread starter Thread starter Luca Bertoldi
  • Start date Start date
L

Luca Bertoldi

Hi all,
I developed a base class that inherits from System.Web.UI.Page and I'd like
to check some cookies in the constructor of the class.
I tried with
if (Context.Request.Cookies["login"] == null) {
Context.Response.Write("<script language='javascript'>document.location='/"
+ currContext.Request.ApplicationPath + "/default.asp?msg=Please, log
on&goto=" + ModuleCode + "';</script>");

Context.Response.End();

}

But even if I previously set the Login cookie, it always evaluates to null
in the check above.

How can it be???

Thanks in advance,

Luca
 
Is your base class getting called from ASP.NET? if not,
it will not have a request object that has the cookies of
the machine.

If you pass the request object in the constructor, Use
that request object to read your cookies rather than the
inherent "Request" object.

Hope that helps,

Keith
-----Original Message-----
Hi all,
I developed a base class that inherits from
System.Web.UI.Page and I'd like
to check some cookies in the constructor of the class.
I tried with
if (Context.Request.Cookies["login"] == null) {
Context.Response.Write("<script language='javascript'>document.location='/"
+ currContext.Request.ApplicationPath + "/default.asp? msg=Please, log
on&goto=" + ModuleCode + "';</script>");

Context.Response.End();

}

But even if I previously set the Login cookie, it always evaluates to null
in the check above.

How can it be???

Thanks in advance,

Luca



.
 
Back
Top