I am using a Site.Master file to create a log in/log out field on every page using the following code:
<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>
However, when the user logs out, I want to be able to run the event handler
OnLoggedOut="LoginStatus1_LoggedOut"
And edit some information in a user table (e.g. last log out time and what not). However, I don’t know how to retrieve this information since
FormsIdentity id = (FormsIdentity)User.Identity;
apparently does not work in Site.Master.cs (User does not exist in context). Is there some other way to retrieve user info? Also, is there a way to transfer information (e.g. using querystring) from the page the user clicked “log out”?
Thanks
Something like this are you looking for?
Or if you need only the UserName…