User.identity。名称为空 [英] User.identity .name is empty

查看:101
本文介绍了User.identity。名称为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用通过认证的会员后,窗体身份验证获得 user.identity.name 空的Web应用程序。

I am getting user.identity.name empty in web application using forms authentication after authenticating through memberships.

我把它重定向到其他形式,但如何跟踪哪些用户登录,我不使用会话。有另一种方式?

I redirect it to other form but how to keep track of which user is logged in, i am not using session. Is there another way?

MembershipUser oCurrentUser = Membership.GetUser();
Response.Write(oCurrentUser.UserName); 

在此也它给我 nullreference例外,但它是正确验证

In this also it is giving me nullreference exception ,though it is validating properly

bCheckUser = Membership.ValidateUser(txtUserName.Text, txtPassword.Text); 

这是返回true。

推荐答案

在看一看<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.setauthcookie.aspx\"相对=nofollow> FormsAuthentication.SetAuthCookie ()

Membership.ValidateUser()是真实的,你应该设置身份验证票证(使用FormsAuthentication.SetAuthCookie)和那么你就可以得到任何其他页面上的 User.Identity 对象。

Once Membership.ValidateUser() is true you should set the authentication ticket (using FormsAuthentication.SetAuthCookie) and then you'll be able to get the User.Identity object on any other page.

这篇关于User.identity。名称为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆