473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

"Profile" and "Session" not accessible in ASP.NET app

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/
Oct 6 '07 #1
4 2082
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
RHello,
RI am writing ASP.NET application in which I need to use User Profiles
Rand
RSession mechanisms.
RHere I include part of my source code (Admin.cs):
Rusing System;
Rusing System.Data;
Rusing System.Data.Sql;
Rusing System.Data.SqlClient;
Rusing System.Data.SqlTypes;
Rusing System.Configuration;
Rusing System.Web;
Rusing System.Web.Security;
Rusing System.Web.SessionState;
Rusing System.Web.Hosting;
Rusing System.Web.Profile;
Rusing System.Diagnostics;
R/// <summary>
R/// Administrative settings and functions
R/// </summary>
Rpublic static class Admin
R{
R/// <summary>
R/// Default database name
R/// </summary>
Rpublic static string DefaultDatabase
R{
Rget
R{
Rif (Profile.Database != null) // HERE PROBLEM #1
Rreturn Profile.Database.ToString();
R...
R}
R}
R/// <summary>
R/// Current database name
R/// </summary>
Rpublic static string Database
R{
Rset
R{
RSession["Database"] = value; // HERE PROBLEM #2
R}
R...
R}
R...
R}
RI have compile-time errors:
R#1: Name "Profile" doesn't exist in current context
R#2: Name "Session" doesn't exist in current context
RIn Web.config I have:
R...
R<profile defaultProvider="SqlProfileProvider">
R<providers>
R<clear/>
R<add name="SqlProfileProvider"
Rtype="System.Web.Profile.SqlProfileProvider"
RconnectionStringName="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>
RCould you tell me please how to use Session and Profile in my code?
RDid I
Rmissed something?
R/RAM/
Oct 6 '07 #2
----- Original Message -----
From: <Michael Nemtsev>; "MVP" <ne*****@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/
Oct 6 '07 #3
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_...t-context.html
"Michael Nemtsev"; "MVP" <ne*****@msn.comwrote in message
news:3d*************************@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

RHello,
RI am writing ASP.NET application in which I need to use User Profiles
Rand
RSession mechanisms.
RHere I include part of my source code (Admin.cs):
Rusing System;
Rusing System.Data;
Rusing System.Data.Sql;
Rusing System.Data.SqlClient;
Rusing System.Data.SqlTypes;
Rusing System.Configuration;
Rusing System.Web;
Rusing System.Web.Security;
Rusing System.Web.SessionState;
Rusing System.Web.Hosting;
Rusing System.Web.Profile;
Rusing System.Diagnostics;
R/// <summary>
R/// Administrative settings and functions
R/// </summary>
Rpublic static class Admin
R{
R/// <summary>
R/// Default database name
R/// </summary>
Rpublic static string DefaultDatabase
R{
Rget
R{
Rif (Profile.Database != null) // HERE PROBLEM #1
Rreturn Profile.Database.ToString();
R...
R}
R}
R/// <summary>
R/// Current database name
R/// </summary>
Rpublic static string Database
R{
Rset
R{
RSession["Database"] = value; // HERE PROBLEM #2
R}
R...
R}
R...
R}
RI have compile-time errors:
R#1: Name "Profile" doesn't exist in current context
R#2: Name "Session" doesn't exist in current context
RIn Web.config I have:
R...
R<profile defaultProvider="SqlProfileProvider">
R<providers>
R<clear/>
R<add name="SqlProfileProvider"
Rtype="System.Web.Profile.SqlProfileProvider"
RconnectionStringName="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...
RRCould you tell me please how to use Session and Profile in my code?
RDid I
Rmissed something?
R/RAM/

Oct 6 '07 #4
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
Oct 6 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: George | last post by:
I am trying to set up a login-logout website. I have a cookie about the login status. I put it as logout once the logout link is clicked. And I put a little security check about the status of...
1
by: AC | last post by:
I have a page class that inherits the System.Web.UI.Page class. Essentially what it does is load a user profile from a session (if it isn't loaded, it loads it into the session) and exposes it via a...
0
by: Angel | last post by:
Hi I have a problem with my web applications. I believe the problem is somehow connected to HttpSession. I use form authentication in my project. Once I authenticate the user and redirect to...
2
by: alain.hogue | last post by:
I known that by using the "Profile_MigrateAnonymous" event I can migrate my anonymous users profile to their authenticated account profile, but I would like to carry over some of the properties of...
5
by: mabond | last post by:
Hi all This question is one of "theory" rather than a search for the specifics of a solution. I need some pointers as to how to proceed with my project. Here goes. My application allows the...
6
by: webonomic | last post by:
"The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty." I get the error above. It tells me the error is in Line 120: ...
3
by: toyaxxx | last post by:
Hello guys, I have hit a dead end in trying to solve this problem. The thing is, I can't run the the program here because it has to run on a server which is in another place. All I receive here is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.