T
tshad
I pulled this from my last question to hopefully make it more clear.
After fixing my namespace problem I still need to find out why I am getting
an error message:
PageInit.cs(43,76): error CS0117: 'object' does not contain a definition for
'LastPageVisited'
User is an object I have in my session variables that works fine in VB.Net
but there is something missing here.
The Compiler Code is:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\csc /t:library PageInit.cs
/r:system.web.dll /r:system.data.dll /r:system.dll
/r:Microsoft.VisualBasic.dll /r:refresh.dll /r:User.dll
The code snippet giving me the problem looks like (the last line is the
offender):
************************************
using System;
using System.Web;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.SessionState;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using Microsoft.VisualBasic;
using MyFunctions;
namespace MyFunctions
{
public class PageInit
{
public static void PageSetup(MyFunctions.Page thePage)
{
HttpContext.Current.Session["LastPageVisited"] =
(User)HttpContext.Current.Session["User"].LastPageVisited;
***********************************
My User class looks something like:
********************************
using System;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using MyFunctions;
using FtsData;
namespace RolesBasedAuthentication
{
[Serializable]
public class User
{
private string lastPageVisited = "";
....
public string LastPageVisited
{
get { return lastPageVisited; }
set { lastPageVisited = value; }
}
....
*************************************
This is the piece that is giving me the problem:
(User)HttpContext.Current.Session["User"].LastPageVisited
As you can see, LastPageVisited is a property of User.
I am still getting this error, even if I change:
HttpContext.Current.Session["LastPageVisited"] =
(User)HttpContext.Current.Session["User"].LastPageVisited;
to
HttpContext.Current.Session["LastPageVisited"] =
(User)(HttpContext.Current.Session["User"]).LastPageVisited;
or
HttpContext.Current.Session["LastPageVisited"] =
(RolesBasedAuthentication.User)(HttpContext.Current.Session["User"]).LastPageVisited;
But the Class User does have a LastPageVisited:
public string LastPageVisited
{
get { return lastPageVisited; }
set { lastPageVisited = value; }
}
Am I casting it wrong??
Thanks,
Tom
After fixing my namespace problem I still need to find out why I am getting
an error message:
PageInit.cs(43,76): error CS0117: 'object' does not contain a definition for
'LastPageVisited'
User is an object I have in my session variables that works fine in VB.Net
but there is something missing here.
The Compiler Code is:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\csc /t:library PageInit.cs
/r:system.web.dll /r:system.data.dll /r:system.dll
/r:Microsoft.VisualBasic.dll /r:refresh.dll /r:User.dll
The code snippet giving me the problem looks like (the last line is the
offender):
************************************
using System;
using System.Web;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.SessionState;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using Microsoft.VisualBasic;
using MyFunctions;
namespace MyFunctions
{
public class PageInit
{
public static void PageSetup(MyFunctions.Page thePage)
{
HttpContext.Current.Session["LastPageVisited"] =
(User)HttpContext.Current.Session["User"].LastPageVisited;
***********************************
My User class looks something like:
********************************
using System;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using MyFunctions;
using FtsData;
namespace RolesBasedAuthentication
{
[Serializable]
public class User
{
private string lastPageVisited = "";
....
public string LastPageVisited
{
get { return lastPageVisited; }
set { lastPageVisited = value; }
}
....
*************************************
This is the piece that is giving me the problem:
(User)HttpContext.Current.Session["User"].LastPageVisited
As you can see, LastPageVisited is a property of User.
I am still getting this error, even if I change:
HttpContext.Current.Session["LastPageVisited"] =
(User)HttpContext.Current.Session["User"].LastPageVisited;
to
HttpContext.Current.Session["LastPageVisited"] =
(User)(HttpContext.Current.Session["User"]).LastPageVisited;
or
HttpContext.Current.Session["LastPageVisited"] =
(RolesBasedAuthentication.User)(HttpContext.Current.Session["User"]).LastPageVisited;
But the Class User does have a LastPageVisited:
public string LastPageVisited
{
get { return lastPageVisited; }
set { lastPageVisited = value; }
}
Am I casting it wrong??
Thanks,
Tom