【发布时间】:2014-09-08 08:53:36
【问题描述】:
所以我按照本教程在 .net 中安装和使用身份框架。 http://www.asp.net/identity/overview/getting-started/adding-aspnet-identity-to-an-empty-or-existing-web-forms-project
在 register.aspx 和 login.aspx 页面上一切正常。
我想从登录页面中获取这个逻辑...
if (User.Identity.IsAuthenticated) {
//do something...
}
并将其放在母版页的 Page_Load 中(以便我可以显示登录或注销链接,具体取决于)
但是,当我这样做时,我收到一条错误消息
当前上下文中不存在名称“用户”
我在母版页后面的代码中有以下“使用”,这里的所有内容都在找到“用户”的 login.aspx 页面上。
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Owin.Security;
using SugarSpun_v2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
我有点困惑!您如何使用母版页上的身份框架?我实际上希望最终将登录表单集成到母版页本身,所以这可能会给我带来问题!
感谢任何帮助,只是刚刚发现了 Indentity Framework,所以请温柔:)
【问题讨论】:
标签: c# .net webforms asp.net-identity