Welcome Guest Search | Active Topics | Members | Log In | Register

"Profile" and "Session" not accessible in ASP.NET app Options · View
Andrew P.
Posted: Saturday, October 06, 2007 7:13:08 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 07:13:08
Date: Sat, 6 Oct 2007 11:13:08 -0400

I don't know what to say about Profile because it appears to be a custom
object, but as for Session, this will probably fix your problem:

http://www.geekpedia.com/Question85_The-name-Session-does-not-exist-in-the-current-context.html


"Michael Nemtsev"; "MVP" <nemtsev@msn.com> wrote in message
news:3d9fba1aed718c9d6902739cf00@msnews.microsoft.com...
> Hello R.A.M.,
>
> What's the the Profile.Database? where did u get this?
>
> ---
> WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
> http://spaces.live.com/laflour
> "The greatest danger for most of us is not that our aim is too high and we
> miss it, but that it is too low and we reach it" (c) Michelangelo
>
> R> Hello,
> R> I am writing ASP.NET application in which I need to use User Profiles
> R> and
> R> Session mechanisms.
> R> Here I include part of my source code (Admin.cs):
> R> using System;
> R> using System.Data;
> R> using System.Data.Sql;
> R> using System.Data.SqlClient;
> R> using System.Data.SqlTypes;
> R> using System.Configuration;
> R> using System.Web;
> R> using System.Web.Security;
> R> using System.Web.SessionState;
> R> using System.Web.Hosting;
> R> using System.Web.Profile;
> R> using System.Diagnostics;
> R> /// <summary>
> R> /// Administrative settings and functions
> R> /// </summary>
> R> public static class Admin
> R> {
> R> /// <summary>
> R> /// Default database name
> R> /// </summary>
> R> public static string DefaultDatabase
> R> {
> R> get
> R> {
> R> if (Profile.Database != null) // HERE PROBLEM #1
> R> return Profile.Database.ToString();
> R> ...
> R> }
> R> }
> R> /// <summary>
> R> /// Current database name
> R> /// </summary>
> R> public static string Database
> R> {
> R> set
> R> {
> R> Session["Database"] = value; // HERE PROBLEM #2
> R> }
> R> ...
> R> }
> R> ...
> R> }
> R> I have compile-time errors:
> R> #1: Name "Profile" doesn't exist in current context
> R> #2: Name "Session" doesn't exist in current context
> R> In Web.config I have:
> R> ...
> R> <profile defaultProvider="SqlProfileProvider">
> R> <providers>
> R> <clear/>
> R> <add name="SqlProfileProvider"
> R> type="System.Web.Profile.SqlProfileProvider"
> R> connectionStringName="SqlServices" applicationName="MIMMagazyn"/>
> R> </providers>
> R> <properties>
> R> <add name="OperatorName" type="String"/>
> R> <add name="Database" type="String"/>
> R> <add name="DefaultStockName" type="String"/>
> R> <add name="DefaultCategoryName" type="String"/>
> R> <add name="Remarks" type="String"/>
> R> </properties>
> R> </profile>
> R> ...
> R> R> Could you tell me please how to use Session and Profile in my code?
> R> Did I
> R> missed something?
> R> /RAM/
>
>

Michael Nemtsev, MVP
Posted: Saturday, October 06, 2007 2:28:44 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 14:28:44
Date: Sat, 6 Oct 2007 14:28:44 +0000 (UTC)

Hello R.A.M.,

What's the the Profile.Database? where did u get this?

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


R> Hello,
R> I am writing ASP.NET application in which I need to use User Profiles
R> and
R> Session mechanisms.
R> Here I include part of my source code (Admin.cs):
R> using System;
R> using System.Data;
R> using System.Data.Sql;
R> using System.Data.SqlClient;
R> using System.Data.SqlTypes;
R> using System.Configuration;
R> using System.Web;
R> using System.Web.Security;
R> using System.Web.SessionState;
R> using System.Web.Hosting;
R> using System.Web.Profile;
R> using System.Diagnostics;
R> /// <summary>
R> /// Administrative settings and functions
R> /// </summary>
R> public static class Admin
R> {
R> /// <summary>
R> /// Default database name
R> /// </summary>
R> public static string DefaultDatabase
R> {
R> get
R> {
R> if (Profile.Database != null) // HERE PROBLEM #1
R> return Profile.Database.ToString();
R> ...
R> }
R> }
R> /// <summary>
R> /// Current database name
R> /// </summary>
R> public static string Database
R> {
R> set
R> {
R> Session["Database"] = value; // HERE PROBLEM #2
R> }
R> ...
R> }
R> ...
R> }
R> I have compile-time errors:
R> #1: Name "Profile" doesn't exist in current context
R> #2: Name "Session" doesn't exist in current context
R> In Web.config I have:
R> ...
R> <profile defaultProvider="SqlProfileProvider">
R> <providers>
R> <clear/>
R> <add name="SqlProfileProvider"
R> type="System.Web.Profile.SqlProfileProvider"
R> connectionStringName="SqlServices" applicationName="MIMMagazyn"/>
R> </providers>
R> <properties>
R> <add name="OperatorName" type="String"/>
R> <add name="Database" type="String"/>
R> <add name="DefaultStockName" type="String"/>
R> <add name="DefaultCategoryName" type="String"/>
R> <add name="Remarks" type="String"/>
R> </properties>
R> </profile>
R> ...
R>
R> Could you tell me please how to use Session and Profile in my code?
R> Did I
R> missed something?
R> /RAM/


R.A.M.
Posted: Saturday, October 06, 2007 5:30:44 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 17:30:44
Date: Sat, 6 Oct 2007 15:30:44 +0200

Hello,
I am writing ASP.NET application in which I need to use User Profiles and
Session mechanisms.
Here I include part of my source code (Admin.cs):

using System;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.Hosting;
using System.Web.Profile;
using System.Diagnostics;

/// <summary>
/// Administrative settings and functions
/// </summary>
public static class Admin
{
/// <summary>
/// Default database name
/// </summary>
public static string DefaultDatabase
{
get
{
if (Profile.Database != null) // HERE PROBLEM #1
return Profile.Database.ToString();
...
}
}

/// <summary>
/// Current database name
/// </summary>
public static string Database
{
set
{
Session["Database"] = value; // HERE PROBLEM #2
}
...
}
...
}

I have compile-time errors:
#1: Name "Profile" doesn't exist in current context
#2: Name "Session" doesn't exist in current context

In Web.config I have:
....
<profile defaultProvider="SqlProfileProvider">
<providers>
<clear/>
<add name="SqlProfileProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="SqlServices" applicationName="MIMMagazyn"/>
</providers>
<properties>
<add name="OperatorName" type="String"/>
<add name="Database" type="String"/>
<add name="DefaultStockName" type="String"/>
<add name="DefaultCategoryName" type="String"/>
<add name="Remarks" type="String"/>
</properties>
</profile>
....

Could you tell me please how to use Session and Profile in my code? Did I
missed something?
/RAM/


R.A.M.
Posted: Saturday, October 06, 2007 7:08:00 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 19:08:00
Date: Sat, 6 Oct 2007 17:08:00 +0200

----- Original Message -----
From: <Michael Nemtsev>; "MVP" <nemtsev@msn.com>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Sent: Saturday, October 06, 2007 4:28 PM
Subject: Re: "Profile" and "Session" not accessible in ASP.NET app


> What's the the Profile.Database? where did u get this?

I wanted to access "Database" profile field for current user. Isn't it a
proper syntax? (My friend told to use Profile.Database). How should I write
it?
/RAM/


Jesse Houwing
Posted: Saturday, October 06, 2007 7:34:19 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 19:34:19
Date: Sat, 6 Oct 2007 19:34:19 +0000 (UTC)

Hello R.A.M.,

Because you're not accessing them from either a page or a user control, there
is no access to these *properties* of the Page and UserControl class.

You can find these from any location by using the static HttpContext.Current
property. Like this: HttpContext.Current.Session and (though I haven't checked)
HttpContext.Current.Profile.

Jesse

> Hello,
> I am writing ASP.NET application in which I need to use User Profiles
> and
> Session mechanisms.
> Here I include part of my source code (Admin.cs):
> using System;
> using System.Data;
> using System.Data.Sql;
> using System.Data.SqlClient;
> using System.Data.SqlTypes;
> using System.Configuration;
> using System.Web;
> using System.Web.Security;
> using System.Web.SessionState;
> using System.Web.Hosting;
> using System.Web.Profile;
> using System.Diagnostics;
> /// <summary>
> /// Administrative settings and functions
> /// </summary>
> public static class Admin
> {
> /// <summary>
> /// Default database name
> /// </summary>
> public static string DefaultDatabase
> {
> get
> {
> if (Profile.Database != null) // HERE PROBLEM #1
> return Profile.Database.ToString();
> ...
> }
> }
> /// <summary>
> /// Current database name
> /// </summary>
> public static string Database
> {
> set
> {
> Session["Database"] = value; // HERE PROBLEM #2
> }
> ...
> }
> ...
> }
> I have compile-time errors:
> #1: Name "Profile" doesn't exist in current context
> #2: Name "Session" doesn't exist in current context
> In Web.config I have:
> ...
> <profile defaultProvider="SqlProfileProvider">
> <providers>
> <clear/>
> <add name="SqlProfileProvider"
> type="System.Web.Profile.SqlProfileProvider"
> connectionStringName="SqlServices" applicationName="MIMMagazyn"/>
> </providers>
> <properties>
> <add name="OperatorName" type="String"/>
> <add name="Database" type="String"/>
> <add name="DefaultStockName" type="String"/>
> <add name="DefaultCategoryName" type="String"/>
> <add name="Remarks" type="String"/>
> </properties>
> </profile>
> ...
>
> Could you tell me please how to use Session and Profile in my code?
> Did I
> missed something?
> /RAM/
--
Jesse Houwing
jesse.houwing at sogeti.nl


Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.1 (NET v2.0) - 9/10/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.074 seconds.