Unable to get Context.User.Identity.Name

A

Arjen

Hi,

I try to get the 'Context.User.Identity.Name' from inside the global.asax in
the 'Application_BeginRequest' event.

I get this error message:
Object reference not set to an instance of an object.

You can simple test this with:
Response.Write(Context.User.Identity.Name);

How can I get there the name?

Thanks!
 
D

Dave Fancher

The identity of the user has not been established when
Application_BeginRequest executes. If you need to access User.Identity,
you'll need to choose another event later in the request's life cycle.

I recommend reading the following document from the Patterns & Practices
site. It should give you a pretty thorough understanding of the life cycle
for an HTTP Request as it relates to ASP.NET.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetAP04.asp

HTH
 
A

Arjen

Hi,

I know the problem, not the solution. I can't find the correct and first
event to get the User.Identity.
Can someone help?

Thanks!
 

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

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,114
Latest member
GlucoPremiumReview
Top