Error using Request and Response

  • Thread starter Thread starter Reena
  • Start date Start date
R

Reena

Hi,

Working on .NET 2003. Using C# as server code.

I have created a class with following code...

using System;
using System.Data.OracleClient;
using System.Web;
using System.Web.SessionState;


namespace RADWebV5.RADAsp.Class
{
public static string LogOn(string UserID, string Password)
{
try
{
HttpCookie cookieABC = Request.Cookies["ABC"];
if (null == cookieABC || cookieABCToString() == "" ||
cookieABC.ToString() != "CI")
{
Response.Cookies["ABC"] = Session["PrimaryCI"];
}
}
catch (Exception err)
{
return err.Source
}
}

__________________

Error while compiling...
The type or namespace name 'Request' could not be found (are you missing a
using directive or an assembly reference?)

The type or namespace name 'Response' could not be found (are you missing a
using directive or an assembly reference?)

_____________________

Not sure what is missing?

Thanks,

- Reena
 
Reena, the HttpRequest and Response are "exposed through the Request
property of the HttpApplication, HttpContext, Page, and UserControl
classes."(from MSDN) So, you need to pass a reference to one of those,
probably your page, or, if you already have a reference to one of these in
this class, just use that ref to access the Request or Response.

Hope that helps.
 
Added reference..

HttpRequest Request = HttpContext.Current.Request;
HttpResponse Response = HttpContext.Current.Response;

Works. Thanks.

- Reena

Greg Ewing said:
Reena, the HttpRequest and Response are "exposed through the Request
property of the HttpApplication, HttpContext, Page, and UserControl
classes."(from MSDN) So, you need to pass a reference to one of those,
probably your page, or, if you already have a reference to one of these in
this class, just use that ref to access the Request or Response.

Hope that helps.

--
Greg Ewing [MVP]
http://www.citidc.com


Reena said:
Hi,

Working on .NET 2003. Using C# as server code.

I have created a class with following code...

using System;
using System.Data.OracleClient;
using System.Web;
using System.Web.SessionState;


namespace RADWebV5.RADAsp.Class
{
public static string LogOn(string UserID, string Password)
{
try
{
HttpCookie cookieABC = Request.Cookies["ABC"];
if (null == cookieABC || cookieABCToString() == "" ||
cookieABC.ToString() != "CI")
{
Response.Cookies["ABC"] = Session["PrimaryCI"];
}
}
catch (Exception err)
{
return err.Source
}
}

__________________

Error while compiling...
The type or namespace name 'Request' could not be found (are you missing a
using directive or an assembly reference?)

The type or namespace name 'Response' could not be found (are you
missing
a
using directive or an assembly reference?)

_____________________

Not sure what is missing?

Thanks,

- Reena
 
Back
Top