473,793 Members | 2,974 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best practice for user/customer repository

Hi,

Until now I used the Session("x")="y " method for saving user or
customer info throw web pages (differently for each session) like that:

Session("UserNa me")="Bob"

My questions:
==========

In Asp.net 1, is there another way, cleaner and structured for doing
the same thing? Something like a class and syntax like
obj_User.UserNa me="Bob" (Important: without the necessity to declare
obj_User in each page!).

Are they any articles on that issue in the web?

Thank You,

Shlomi

Apr 17 '06 #1
5 1396
Ok, create the following class , this can be called from within another
class beit, page or one of your own. You should set this on session start to
the users name. So the users name call bed called CurrentUser.Nam e

Public Class CurrentUser

Public Shared Property Name()
Get
Return HttpContext.Cur rent.Session("U serName")
End Get
Set(ByVal value)
HttpContext.Cur rent.Session("U serName") = value
End Set
End Property

End Class

--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net
"Shlomi" <sh*****@gmail. com> wrote in message
news:11******** ************@z3 4g2000cwc.googl egroups.com...
Hi,

Until now I used the Session("x")="y " method for saving user or
customer info throw web pages (differently for each session) like that:

Session("UserNa me")="Bob"

My questions:
==========

In Asp.net 1, is there another way, cleaner and structured for doing
the same thing? Something like a class and syntax like
obj_User.UserNa me="Bob" (Important: without the necessity to declare
obj_User in each page!).

Are they any articles on that issue in the web?

Thank You,

Shlomi

Apr 17 '06 #2
Yes, but how to avoid declaring an instance of a class in each page
that I approach?
Do I have to use session variable anyhow?

Apr 17 '06 #3
Hi,

Have you thought of using forms authentication?

Then you have available ..

HttpContext.Cur rent.User

Wozza

"Shlomi" wrote:
Hi,

Until now I used the Session("x")="y " method for saving user or
customer info throw web pages (differently for each session) like that:

Session("UserNa me")="Bob"

My questions:
==========

In Asp.net 1, is there another way, cleaner and structured for doing
the same thing? Something like a class and syntax like
obj_User.UserNa me="Bob" (Important: without the necessity to declare
obj_User in each page!).

Are they any articles on that issue in the web?

Thank You,

Shlomi

Apr 17 '06 #4
You dont need to instantiate it, the property is shared.

--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net
"Shlomi" <sh*****@gmail. com> wrote in message
news:11******** *************@u 72g2000cwu.goog legroups.com...
Yes, but how to avoid declaring an instance of a class in each page
that I approach?
Do I have to use session variable anyhow?

Apr 17 '06 #5

Check my blog
http://spaces.msn.com/sholliday/ 10/24/2005 entry

I have a cleaner way to store objects in the SESSION variable.

I'd create an object

class UserInfo
{
public string UserName
{ get { return this.m_myname; }}

}

and use my wrapper object to store instantiations of this object.

...

"Shlomi" <sh*****@gmail. com> wrote in message
news:11******** ************@z3 4g2000cwc.googl egroups.com...
Hi,

Until now I used the Session("x")="y " method for saving user or
customer info throw web pages (differently for each session) like that:

Session("UserNa me")="Bob"

My questions:
==========

In Asp.net 1, is there another way, cleaner and structured for doing
the same thing? Something like a class and syntax like
obj_User.UserNa me="Bob" (Important: without the necessity to declare
obj_User in each page!).

Are they any articles on that issue in the web?

Thank You,

Shlomi

Apr 17 '06 #6

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

Similar topics

136
9460
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
14
3141
by: 42 | last post by:
Hi, Stupid question: I keep bumping into the desire to create classes and properties with the same name and the current favored naming conventions aren't automatically differentiating them... (both are "Pascal Case" with no leading or trailing qualifiers). For example... I'll be modelling something, e.g. a computer, and I'll
17
8042
by: | last post by:
I have an app that retrieves data from an Access database. At the moment I have the SQL string as a Const in my app. I understand this is not best practice. I don't want the user to have access to read or modify this string so I don't want to store it in an INI / Text file or in registery. Can someone please tell me the best practice for this. Thanks Mike
0
772
by: Chris Lane | last post by:
Hi, I work with a developer who thinks it is a best practice to have a shared method in a Customer Class that returns a collection of Customers. In my humble opinion we should have a Collection Builder class or go directly to the data layer and have the data layer return the collection of Customer objects depending upon how much you wish to abstract your data Layer. To me it just seems odd to have the individual Customer class create...
10
1992
by: Mike Logan | last post by:
I am using the "contract first" design methodology. Contract First is design the WSDL first then design the server and client. However I must design my XSD/XML Schema before anything. I am developing my schema now. I have a version on my schema. However once I start the server side code, how is the server now that the right "complexType" is being passed? What happens if this complexType my web service consumes needs to be...
4
2432
by: Tarun Mistry | last post by:
Hi all, I have posted this in both the c# and asp.net groups as it applies to both (apologies if it breaks some group rules). I am making a web app in asp.net using c#. This is the first fully OO application I will be making, also my first .NET application, so im looking for any help and guidance. Ok, my problems are todo with object and database abstraction, what should i do.
6
1467
by: AlexT | last post by:
Folks Please bear with me - I'm not a real ASP pro... I need some advice about the following problem: I have "inherited" of a working ASP site which is hosted on a collocated IIS machine. At some point the site offers the possibility for any user to fill a
1
1415
by: DelphiLover | last post by:
Hi. I'm reading and reading, testing and testing, trying to figure out how to do things, how to do things according to best practises and how to do things in the best object oriented way. So... Best practises, in good object oriented fashion: how do I do it. I'm thinking making classes for data access. An Example that ALL books do - customer - and orders. So I'm thinking: Making a customer class
3
3064
by: Ant | last post by:
Hi, I'm using a modal dialog box to input data. I have created properties on the dialog form to capture the data so that it might be read from the main form via the dialog form. This approach encapsulates the data & I can implement the business logic in the dialog form. This leaves me with the quiestion. There is no Class representing the data I'm capturing, (say, it's a customer) apart from the dialog form class. The form now...
0
9670
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
9518
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
10211
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10159
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
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...
1
7538
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
6776
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();...
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2917
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.