在一个页面中写入:

 FormsAuthentication.SetAuthCookie(username, true);

在另一个页面中写入:

string name = Page.User.Identity.Name;

获取不到值的原因:

在web.config中加入:

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

相关文章:

  • 2021-11-15
  • 2022-12-23
  • 2021-07-15
  • 2022-01-21
  • 2021-09-29
  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-08
  • 2022-12-23
  • 2021-07-14
  • 2021-12-11
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案