web applications - Current user with ASP.NET Forms authentication app -
i trying retrieve current user in web application uses asp.net forms authentication. however, system.security.principal.windowsidentity.getcurrent().name returns domain\windowsuser, not username used in formsauthentication.redirectfromloginpage method. using forms authentication in config file:
<authentication mode="forms"> <forms loginurl="views/login.aspx" name=".aspxformsauth" timeout="1" cookieless="useuri"> </forms> </authentication> <authorization> <deny users="?" /> </authorization> i trying follow microsoft's walk through , retrieve authentication ticket using following snippet:
if (request.isauthenticated) { var ident = user.identity formsidentity; if (ident != null) { formsauthenticationticket ticket = ident.ticket; var name = ticket.name; } } however, ident null because it's windowsidentity not formsidentity. what's wrong here? thank you!
use user.identity.name user name.
windows authentication not use formsauthenticationticket.
Comments
Post a Comment