Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: How to add Page.User.Identity.Name into a class file?

Thread Tools

Re: How to add Page.User.Identity.Name into a class file?

Gregory A. Beamer
Posts: n/a
"aspfun via" <u53138@uwe> wrote in

> I use Page.User.Identity.Name to get user's login ID but it only works
> in the page.
> I want to add it into a class file but got an error said:
> Reference to non-shared member requires an object reference
> How fix it?

Mark already answered how to do it. Now I am going to tell you why you
should not do it and instead add the identity as a variable to the class
or routine in question.

When you pull from HttpContext in a library, you end up ensuring the
library cannot be used by anything other than a web application. This
may be okay, but realize the coupling becomes a constraint if, for
example, management wants a WPF application with the same code base.

You can create a UI only class library to handle the pull from
HttpContext, with windows specific UI class lib(s) for other apps, but
it makes things a bit dicier to maintain.

In the long run, feeding the application from UI is a better option.

Peace and Grace,

Gregory A. Beamer

Twitter: @gbworld

| Think outside the box! |
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Class A contains class B, class B points to class A Joseph Turian C++ 5 12-30-2005 03:24 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
procedure to add web reference which will not create new namespace just add class in existing namespace. Deep Mehta via .NET 247 ASP .Net Web Services 2 05-31-2005 05:05 AM
A parameterized class (i.e. template class / class template) is not a class? christopher diggins C++ 16 05-04-2005 12:26 AM