Thursday, May 12, 2005

Why Context.User.Identity.Name returns blank ?

One of my friends mailed on our INETA User Group mailing list asking that he is unable to recieve the name associated with Windows Identity object in his asp.net web application. He further claimed that he had set "authentication mode" to "windows authentication".

Following was my response to that:

check that if the current user is authenticated or not. u may try this if block:

if(this.Context.User.Identity.IsAuthenticated)


and if u come to know that the user is not authenticated (which i am sure u will find) then this means that like most of us u have enabled anonymous access. try disabling it and then run ur code by selecting windows authentication mode in your directory security settings in IIS.

2 comments:

Rahul said...

hi really ur answer is wonderful. You have saved a lot of time for me..

Thanks
Rahul.

Anonymous said...

Do u mean to say that if I do Anonymous access ; every time the Context.User.Identity.IsAuthenticated wil be false ? ..


If this is so then how come the web-page is being accessed ?

Botton line is that is IsAuthenticated is false then the uses shoud not be allowed to access the page. ( in context of Anonymous access enabled)

Ankit
ankitbhurat@gmail.com