you could write a method like this and should work. But without the query your are testing its hard to tell
public int AppUserID
{
get
{
object AppUserID= Session["AppUserID"] as object;
if (AppUserID == null)
{
int AppUserID= -1;
return AppUserID;
}
else
return AppUserID== null ? null : AppUserID as int;
}
set
{
Session["AppUserID"] = value;
}
}