Error using Request and Response

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Reena

    #1

    Error using Request and Response

    Hi,

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

    I have created a class with following code...

    using System;
    using System.Data.Ora cleClient;
    using System.Web;
    using System.Web.Sess ionState;


    namespace RADWebV5.RADAsp .Class
    {
    public static string LogOn(string UserID, string Password)
    {
    try
    {
    HttpCookie cookieABC = Request.Cookies["ABC"];
    if (null == cookieABC || cookieABCToStri ng() == "" ||
    cookieABC.ToStr ing() != "CI")
    {
    Response.Cookie s["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


  • Greg Ewing [MVP]

    #2
    Re: Error using Request and Response

    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]
    IT support built exclusively for nonprofits. 25 years of managed IT, help desk, and cybersecurity - so your team can focus on your mission.



    "Reena" <palejar@navsea .navy.mil> wrote in message
    news:#RjxqxqhDH A.604@TK2MSFTNG P10.phx.gbl...[color=blue]
    > Hi,
    >
    > Working on .NET 2003. Using C# as server code.
    >
    > I have created a class with following code...
    >
    > using System;
    > using System.Data.Ora cleClient;
    > using System.Web;
    > using System.Web.Sess ionState;
    >
    >
    > namespace RADWebV5.RADAsp .Class
    > {
    > public static string LogOn(string UserID, string Password)
    > {
    > try
    > {
    > HttpCookie cookieABC = Request.Cookies["ABC"];
    > if (null == cookieABC || cookieABCToStri ng() == "" ||
    > cookieABC.ToStr ing() != "CI")
    > {
    > Response.Cookie s["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[/color]
    a[color=blue]
    > using directive or an assembly reference?)
    >
    > _______________ ______
    >
    > Not sure what is missing?
    >
    > Thanks,
    >
    > - Reena
    >
    >[/color]


    Comment

    • Reena

      #3
      Re: Error using Request and Response

      Added reference..

      HttpRequest Request = HttpContext.Cur rent.Request;
      HttpResponse Response = HttpContext.Cur rent.Response;

      Works. Thanks.

      - Reena

      "Greg Ewing [MVP]" <gewing@_NO_SPA M_gewing.com> wrote in message
      news:OcvRBErhDH A.2248@TK2MSFTN GP12.phx.gbl...[color=blue]
      > 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" <palejar@navsea .navy.mil> wrote in message
      > news:#RjxqxqhDH A.604@TK2MSFTNG P10.phx.gbl...[color=green]
      > > Hi,
      > >
      > > Working on .NET 2003. Using C# as server code.
      > >
      > > I have created a class with following code...
      > >
      > > using System;
      > > using System.Data.Ora cleClient;
      > > using System.Web;
      > > using System.Web.Sess ionState;
      > >
      > >
      > > namespace RADWebV5.RADAsp .Class
      > > {
      > > public static string LogOn(string UserID, string Password)
      > > {
      > > try
      > > {
      > > HttpCookie cookieABC = Request.Cookies["ABC"];
      > > if (null == cookieABC || cookieABCToStri ng() == "" ||
      > > cookieABC.ToStr ing() != "CI")
      > > {
      > > Response.Cookie s["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[/color][/color]
      a[color=blue][color=green]
      > > using directive or an assembly reference?)
      > >
      > > The type or namespace name 'Response' could not be found (are you[/color][/color]
      missing[color=blue]
      > a[color=green]
      > > using directive or an assembly reference?)
      > >
      > > _______________ ______
      > >
      > > Not sure what is missing?
      > >
      > > Thanks,
      > >
      > > - Reena
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...