Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 715
  • Last Modified:

Name 'User' is not declared

I need to refer to User.Identity.Name within a class in the App_Code folder.  When I use User.Identity.Name I get an error saying

Name 'User' is not declared

Can anyone tell me the correct syntax for reading this value?  Thank you.
0
Rouchie
Asked:
Rouchie
  • 2
1 Solution
 
levyukCommented:
That is the correct syntax.
0
 
RouchieAuthor Commented:
Sorry, then how do I retrieve the value usually returned when my normal pages read this?  The value is set originally using forms authentication in global.asax.
From that point on every page can access user.identity.name no problem, however, within this class I get the error above.  I'm sure I need to do something else to reference it, but aren't sure what...
0
 
GavinMannionCommented:
You will need

HttpContext.Current.User.Identity.Name
0
 
RouchieAuthor Commented:
That's the one!
Thank you!  :-D
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now