Introduction
Here I will explain how to solve problem of HttpContext.Current.User.Identity.Name returns null or empty string value.
Dsecription
I have one requirement like getting system username based on that check the permissions of user if user has sufficient permission I need to allow that person to view the particular page otherwise I don’t want give chance to show the page for that I have written code to get username like this
string username = HttpContext.Current.User.Identity.Name.ToLower(); |
After that I run the application un expectdly I got username as null at that time again I checked my code to get username correctly at that time I found the mistake that is in web.config I write the authentication like this
<authentication mode="Forms"/> |
Because of authentication mode="Forms" I got username is null that’s why I change th e authentication mode to Windows like this
<authentication mode="Windows"/> |
Again I run the application and checked for username now I got the username successfully.
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
5 comments :
Good Articals
Hello Im using web application which gets username from windows login.when I deploy it in Local IIS or server it shows empty.Note:In web.config it is only.Kindly reply....
Excellent tip
Amazing work!
Really helpful.
Note: Only a member of this blog may post a comment.