Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NET注销事件处理程序和Site.Master页_Asp.net_Forms_Web - Fatal编程技术网

ASP.NET注销事件处理程序和Site.Master页

ASP.NET注销事件处理程序和Site.Master页,asp.net,forms,web,Asp.net,Forms,Web,我正在使用Site.Master文件在每个页面上使用以下代码创建登录/注销字段: <asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false" > <AnonymousTemplate> [ <a href="~/Account/Login.aspx" ID="HeadLoginStatus" runat="se

我正在使用Site.Master文件在每个页面上使用以下代码创建登录/注销字段:

<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false" >
                <AnonymousTemplate>
                    [ <a href="~/Account/Login.aspx" ID="HeadLoginStatus" runat="server">Log In</a> ]
                </AnonymousTemplate>
                <LoggedInTemplate>
                    Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
                    [ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" OnLoggedOut="LoginStatus1_LoggedOut" LogoutPageUrl="~/"/> ]
                </LoggedInTemplate>
</asp:LoginView>
并编辑用户表中的某些信息(例如上次注销时间等)。但是,我不知道如何检索这些信息,因为

FormsIdentity id = (FormsIdentity)User.Identity;
显然在Site.Master.cs中不起作用(上下文中不存在用户)。是否有其他方法检索用户信息?此外,是否有方法从用户单击“注销”的页面传输信息(例如使用querystring)


谢谢你要找这样的东西吗

System.Security.Principal.IIdentity id = HttpContext.Current.User.Identity;
或者如果你只需要用户名

String id = HttpContext.Current.User.Identity.Name
String id = HttpContext.Current.User.Identity.Name