Page.User.Identity.Name获取不到值

在一个页面中写入:

 FormsAuthentication.SetAuthCookie(username, true);

在另一个页面中写入:

string name = Page.User.Identity.Name;

获取不到值的原因:

在web.config中加入:

<authentication mode="Forms">
<forms loginUrl="XXX.aspx" timeout="XXX" />
</authentication>

posted on 2016-05-09 16:53  FIGHTING360  阅读(1057)  评论(0编辑  收藏  举报