Session error

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

    #1

    Session error

    Hi,

    I am working on .NET 2003, C#. I have created a class file and getting...

    The name 'Session' does not exist in the class or namespace
    'RADWebV5.RADAs p.Class.Connect ion'

    Connection.cs code....

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

    namespace RADWebV5.RADAsp .Class
    {
    /// <summary>
    /// Summary description for Connection.
    /// </summary>
    public class Connection
    {
    public Connection()
    {
    //
    // TODO: Add constructor logic here
    //
    }

    public static string LogOn(string UserID, string Password)
    {
    OracleConnectio n objConnection = null;
    OracleDataReade r objReader = null;

    try
    {
    Session["UserID"] = UserID;
    Session["Password"] = Password;
    }

    catch (Exception err)
    {
    return "Source : " + err.Source + "\nMessage : " + err.Message;
    }

    finally
    {
    if (objReader != null)
    {
    objReader.Close ();
    objReader.Dispo se();
    }
    if (objConnection != null)
    {
    objConnection.C lose();
    objConnection.D ispose();
    }
    }
    }

    }
    }

    _______________ ________

    Not sure what I am doing wrong.

    Thanks,

    - Reena




  • Leon Jollans

    #2
    Re: Session error

    HttpContext.Cur rent.Session if you're out of the Page scope.
    You could add the line

    HttpSessionStat e Session = HttpContext.Cur rent.Session;

    into the class initialisation.

    hth
    Leon

    "Reena" <palejar@navsea .navy.mil> wrote in message
    news:#hGrqHSgDH A.1888@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Hi,
    >
    > I am working on .NET 2003, C#. I have created a class file and getting...
    >
    > The name 'Session' does not exist in the class or namespace
    > 'RADWebV5.RADAs p.Class.Connect ion'
    >
    > Connection.cs code....
    >
    > using System;
    > using System.Data.Ora cleClient;
    > using System.Web.Sess ionState;
    >
    > namespace RADWebV5.RADAsp .Class
    > {
    > /// <summary>
    > /// Summary description for Connection.
    > /// </summary>
    > public class Connection
    > {
    > public Connection()
    > {
    > //
    > // TODO: Add constructor logic here
    > //
    > }
    >
    > public static string LogOn(string UserID, string Password)
    > {
    > OracleConnectio n objConnection = null;
    > OracleDataReade r objReader = null;
    >
    > try
    > {
    > Session["UserID"] = UserID;
    > Session["Password"] = Password;
    > }
    >
    > catch (Exception err)
    > {
    > return "Source : " + err.Source + "\nMessage : " + err.Message;
    > }
    >
    > finally
    > {
    > if (objReader != null)
    > {
    > objReader.Close ();
    > objReader.Dispo se();
    > }
    > if (objConnection != null)
    > {
    > objConnection.C lose();
    > objConnection.D ispose();
    > }
    > }
    > }
    >
    > }
    > }
    >
    > _______________ ________
    >
    > Not sure what I am doing wrong.
    >
    > Thanks,
    >
    > - Reena
    >
    >
    >
    >[/color]


    Comment

    • Reena

      #3
      Re: Session error

      Thanks Leon. Works.

      "Leon Jollans" <Leon.JollansRE MOVE__THIS@xama n.com> wrote in message
      news:%23OwnSNSg DHA.1760@TK2MSF TNGP09.phx.gbl. ..[color=blue]
      > HttpContext.Cur rent.Session if you're out of the Page scope.
      > You could add the line
      >
      > HttpSessionStat e Session = HttpContext.Cur rent.Session;
      >
      > into the class initialisation.
      >
      > hth
      > Leon
      >
      > "Reena" <palejar@navsea .navy.mil> wrote in message
      > news:#hGrqHSgDH A.1888@TK2MSFTN GP12.phx.gbl...[color=green]
      > > Hi,
      > >
      > > I am working on .NET 2003, C#. I have created a class file and[/color][/color]
      getting...[color=blue][color=green]
      > >
      > > The name 'Session' does not exist in the class or namespace
      > > 'RADWebV5.RADAs p.Class.Connect ion'
      > >
      > > Connection.cs code....
      > >
      > > using System;
      > > using System.Data.Ora cleClient;
      > > using System.Web.Sess ionState;
      > >
      > > namespace RADWebV5.RADAsp .Class
      > > {
      > > /// <summary>
      > > /// Summary description for Connection.
      > > /// </summary>
      > > public class Connection
      > > {
      > > public Connection()
      > > {
      > > //
      > > // TODO: Add constructor logic here
      > > //
      > > }
      > >
      > > public static string LogOn(string UserID, string Password)
      > > {
      > > OracleConnectio n objConnection = null;
      > > OracleDataReade r objReader = null;
      > >
      > > try
      > > {
      > > Session["UserID"] = UserID;
      > > Session["Password"] = Password;
      > > }
      > >
      > > catch (Exception err)
      > > {
      > > return "Source : " + err.Source + "\nMessage : " + err.Message;
      > > }
      > >
      > > finally
      > > {
      > > if (objReader != null)
      > > {
      > > objReader.Close ();
      > > objReader.Dispo se();
      > > }
      > > if (objConnection != null)
      > > {
      > > objConnection.C lose();
      > > objConnection.D ispose();
      > > }
      > > }
      > > }
      > >
      > > }
      > > }
      > >
      > > _______________ ________
      > >
      > > Not sure what I am doing wrong.
      > >
      > > Thanks,
      > >
      > > - Reena
      > >
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...