Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > get user identity in user control

Reply
Thread Tools

get user identity in user control

 
 
=?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=
Guest
Posts: n/a
 
      10-25-2005
I've created a simple function to capture the userid when a page is hit. I
can include this function in the page load using if not ispostback, but i'd
perfer to place it in the page load event of the user control i have created
for navigation. However, the user object does not appear to be available. Is
there a way around this? or am i doing something wrong?

(additional note: i also tried putting it in the global.asax but get an
error.)
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q3VydF9DIFtNVlBd?=
Guest
Posts: n/a
 
      10-25-2005
Parent.Page

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



"WebBuilder451" wrote:

> I've created a simple function to capture the userid when a page is hit. I
> can include this function in the page load using if not ispostback, but i'd
> perfer to place it in the page load event of the user control i have created
> for navigation. However, the user object does not appear to be available. Is
> there a way around this? or am i doing something wrong?
>
> (additional note: i also tried putting it in the global.asax but get an
> error.)
> --
> thanks (as always)
> some day i''m gona pay this forum back for all the help i''m getting
> kes

 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      10-25-2005
Kes,

Check your include files/references in the regular .aspx page. Whichever
object you're using to obtain user identity is being referenced by the .aspx
page, but not by the user control. Also, in case the object is already being
referenced by the user control (which is likely) try creating it via it's
full path name.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"WebBuilder451" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I've created a simple function to capture the userid when a page is hit. I
> can include this function in the page load using if not ispostback, but
> i'd
> perfer to place it in the page load event of the user control i have
> created
> for navigation. However, the user object does not appear to be available.
> Is
> there a way around this? or am i doing something wrong?
>
> (additional note: i also tried putting it in the global.asax but get an
> error.)
> --
> thanks (as always)
> some day i''m gona pay this forum back for all the help i''m getting
> kes



 
Reply With Quote
 
=?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=
Guest
Posts: n/a
 
      10-25-2005
I guess i was hoping the user control would have access to the user identity
after it was included on the page. this would save me from calling the
function (created as component) on each aspx page in the site. So far the
user is found on each page with out problem even when it does not exist (as
Null or blank). however, i can't help feeling i'm missing something.

page pg1.aspx has control uctrl1.ascx (as does all other pages on the site).
With out directly referencing pg1.aspx can i get the user identity?
thanks
kes

--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes


"S. Justin Gengo" wrote:

> Kes,
>
> Check your include files/references in the regular .aspx page. Whichever
> object you're using to obtain user identity is being referenced by the .aspx
> page, but not by the user control. Also, in case the object is already being
> referenced by the user control (which is likely) try creating it via it's
> full path name.
>
> --
> Sincerely,
>
> S. Justin Gengo, MCP
> Web Developer / Programmer
>
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzsche
> "WebBuilder451" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I've created a simple function to capture the userid when a page is hit. I
> > can include this function in the page load using if not ispostback, but
> > i'd
> > perfer to place it in the page load event of the user control i have
> > created
> > for navigation. However, the user object does not appear to be available.
> > Is
> > there a way around this? or am i doing something wrong?
> >
> > (additional note: i also tried putting it in the global.asax but get an
> > error.)
> > --
> > thanks (as always)
> > some day i''m gona pay this forum back for all the help i''m getting
> > kes

>
>
>

 
Reply With Quote
 
mkaouri mkaouri is offline
Junior Member
Join Date: Dec 2007
Posts: 1
 
      12-31-2007
Good day ,

I've done it before inside SqlSiteMapProvider.cs and it works; then I've used it later in one of my .ascx user control and it works too.

So just add the following to your string control or variable:

HttpContext.Current.User.Identity.Name

or

System.Web.HttpContext.Current.User.Identity.Name

example: String getusername = HttpContext.Current.User.Identity.Name;
 
Reply With Quote
 
AlbertM. AlbertM. is offline
Junior Member
Join Date: Apr 2008
Posts: 5
 
      04-02-2008
Thanks to "mkaouri",

I've been in forums all day and your simple example worked perfect!
 
Reply With Quote
 
 
 
Reply

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
Membership functions connect to Sql Server as Process Identity, not user identity?? andrew.sher@gmail.com ASP .Net Security 6 04-16-2006 10:37 PM
HttpContext.Current.User.Identity.Name AND Context.User.Identity.Name; nalbayo ASP .Net 2 11-11-2005 11:12 PM
Difference between System.Web.HttpContext.Current.User.Identity.Name and System.Threading.Thread.CurrentPrincipal.Identity.Name jeremy.rice@alkermes.com ASP .Net Security 5 11-08-2005 05:25 PM
Issue with Identity Impersonation and user identity used passed for trusted SQL connection. Frederick D'hont ASP .Net Security 0 07-25-2005 02:41 PM
Difference between HttpContext.Current.User.Identity and identity Impersonation Giovanni Bassi ASP .Net 0 10-20-2003 02:25 PM



Advertisments