Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

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.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

5 comments :

Anonymous said...

Good Articals

Anonymous said...

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....

Rakesh said...

Excellent tip

hermes said...

Amazing work!

submit said...

Really helpful.

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.