getting Page.User

N

Ned White

Hi All,

In C# web projects , i can get some current user info with
"this.Page.User.Identity" in aspx pages and can use them like that;
this.Page.User.Identity.IsAuthenticated
this.Page.User.Identity.Name
etc.

But in a separate .cs class file how can i get this current user info ?
which namespaces should i use ?

Thanks....

RED
 
M

Michael Nemtsev [MVP]

Hello Ned,

HttpContext.Current.User.*

---
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


NW> Hi All,
NW>
NW> In C# web projects , i can get some current user info with
NW> "this.Page.User.Identity" in aspx pages and can use them like that;
NW> this.Page.User.Identity.IsAuthenticated
NW> this.Page.User.Identity.Name
NW> etc.
NW> But in a separate .cs class file how can i get this current user
NW> info ? which namespaces should i use ?
NW>
NW> Thanks....
NW>
NW> RED
NW>
 
A

Anthony Jones

Ned White said:
Hi All,

In C# web projects , i can get some current user info with
"this.Page.User.Identity" in aspx pages and can use them like that;
this.Page.User.Identity.IsAuthenticated
this.Page.User.Identity.Name
etc.

But in a separate .cs class file how can i get this current user info ?
which namespaces should i use ?

You need System.Web and System.Web.UI

Page page = (Page)HttpContext.Current.CurrentHandler

Now you can access the page User property etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,176
Messages
2,570,947
Members
47,498
Latest member
log5Sshell/alfa5

Latest Threads

Top