473,748 Members | 7,217 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET 2.0 Profile variable replaces Session except 'profile' does not exist in the current context err

Hi,

It seems as though Profiles have replaced session variables in visual
studio 2005. The Profile needs to be defined in the web.config :
<anonymousIdent ification enabled="true" />
<profile enabled="true">
<properties>
<add name="EmpNum" defaultValue="? ?" allowAnonymous= "true" />
</properties>
</profile>

And accessed from as page as Profile["EmpNum"] = "Test"

except I get the 'profile' does not exist in the current
context.....any ideas?

thanks

Jul 11 '06 #1
3 1874
Profile does not "replace" Session. It's designed for user-specific settings
and information that typically are needed to enhance the user experience.
Custom profile information could include site setting preference, or things
like address and email information.

Profile is not accessed the same way as Session.

Hope this helps.
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"j-in-uk" wrote:
Hi,

It seems as though Profiles have replaced session variables in visual
studio 2005. The Profile needs to be defined in the web.config :
<anonymousIdent ification enabled="true" />
<profile enabled="true">
<properties>
<add name="EmpNum" defaultValue="? ?" allowAnonymous= "true" />
</properties>
</profile>

And accessed from as page as Profile["EmpNum"] = "Test"

except I get the 'profile' does not exist in the current
context.....any ideas?

thanks

Jul 11 '06 #2
Hi,

Ok thanks, I know the difference now but I still seem to have a problem
accessing the Profile properties setup in the web.config.

Peter wrote:
Profile does not "replace" Session. It's designed for user-specific settings
and information that typically are needed to enhance the user experience.
Custom profile information could include site setting preference, or things
like address and email information.

Profile is not accessed the same way as Session.

Hope this helps.
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"j-in-uk" wrote:
Hi,

It seems as though Profiles have replaced session variables in visual
studio 2005. The Profile needs to be defined in the web.config :
<anonymousIdent ification enabled="true" />
<profile enabled="true">
<properties>
<add name="EmpNum" defaultValue="? ?" allowAnonymous= "true" />
</properties>
</profile>

And accessed from as page as Profile["EmpNum"] = "Test"

except I get the 'profile' does not exist in the current
context.....any ideas?

thanks
Jul 11 '06 #3
Example:

protected void Page_Load(objec t sender, EventArgs e) {

Country.Text = Profile.Country ;

Gender.Text = Profile.Gender;

Age.Text = Profile.Age.ToS tring();

RoleList.DataSo urce = Roles.GetRolesF orUser(User.Ide ntity.Name);

RoleList.DataBi nd();

}
See this post by Scott Guthrie ("Mr. ASP.NET") for details:

http://weblogs.asp.net/scottgu/archi...18/427754.aspx
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"j-in-uk" wrote:
Hi,

Ok thanks, I know the difference now but I still seem to have a problem
accessing the Profile properties setup in the web.config.

Peter wrote:
Profile does not "replace" Session. It's designed for user-specific settings
and information that typically are needed to enhance the user experience.
Custom profile information could include site setting preference, or things
like address and email information.

Profile is not accessed the same way as Session.

Hope this helps.
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"j-in-uk" wrote:
Hi,
>
It seems as though Profiles have replaced session variables in visual
studio 2005. The Profile needs to be defined in the web.config :
<anonymousIdent ification enabled="true" />
<profile enabled="true">
<properties>
<add name="EmpNum" defaultValue="? ?" allowAnonymous= "true" />
</properties>
</profile>
>
And accessed from as page as Profile["EmpNum"] = "Test"
>
except I get the 'profile' does not exist in the current
context.....any ideas?
>
thanks
>
>

Jul 11 '06 #4

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

Similar topics

134
7897
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that means that if I misspell a variable name, my program will mysteriously fail to work with no error message. If you don't declare variables, you can inadvertently re-use an variable used in an enclosing context when you don't intend to, or
5
2653
by: Filip | last post by:
Hello, (ASP.NET c#) I want to put some common functions into one class and within this class I need to have access to the Session, Request and Response. This class is not page behind file! I keep trying all sorts of namespaces, but to no avail. Keep getting: "The name 'Session' does not exist in the class or namespace 'xyz xyz xyz'" and "The type or namespace name 'Page' could not be found (are you missing a using directive or an...
0
2187
by: Rodusa | last post by:
I am trying to replace cookies with the new "Asp.net 2.0 profiles" in my shopping cart application, but I am having trouble to access profile properties using HttpContext.Current.Profile. I can access any other property property of this class from a regular aspx page, but not from inside the class itself. This is the piece of the code that I am trying to get to work which can also be located at the bottom of the page, but so far just...
0
800
by: Maciek | last post by:
Hi When I set Session state mode to StateServer (IIS 6.0; windows2003; .NET 2.0) in my application, I have recived this message: ----------------------------------------------------------------------------------------------------------------- Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same. If the server is on a...
8
2577
by: bmukulu | last post by:
Hi, I am trying to add some error handling in a Global.asax file. I am declaring a session variable within the Application_Error procedure. However, everytime i try to pass something into the sessionstate i get a error message of 'Object reference not set to an instance of an object.' Is there any workaround for this? And why am I getting this error? Thanks in advance
11
11477
by: Dave | last post by:
I have a site with an App_Code folder that has Global.asax.cs and a file named Upload.cs. I want to pass Upload.cs a Session variable (username) that is set in default.aspx. Setting up a session variable in default.aspx is no problem, but how do I make it available to Upload.cs? I think it's a matter of writting code into the following two files: Global.asax.cs, and obviously, Upload.cs, but how exactly is it done?
7
3984
by: Rusty Hill | last post by:
I have a base class that contains code for the profile object that works fine when the code is not in a file within the App_Code folder. Once I put the code into the App_Code folder it will no longer compiling telling me: "The name 'Profile' does not exist in the current context" What am I missing here (besides a clue)?
4
2106
by: R.A.M. | last post by:
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;
4
2501
by: Scott M. | last post by:
When profile data is stored in ASP .NET, where is the user data persisted? For how long is it persisted: is it session persisted or permanent (like a cookie)?
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9247
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8243
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.