如何使用html在asp.net中结束会话
本文关键字:结束 会话 net asp 何使用 html | 更新日期: 2023-09-27 18:00:05
我想知道当用户从导航栏单击"注销"时,如何结束或清除会话?我正在使用<a></a>
标签,似乎无法思考如何结束会话。
下面是我的代码,这就是我如何制作标签的,我不知道我可以把会话结束命令放在哪里。我该怎么做?谢谢
<div class ="navbar navbar-inverse navbar-fixed-top" style="background-color:cornflowerblue">
<div class="container-fluid">
<a class="navbar-brand" href="Default.aspx" runat="server" style="color:white; font-family:FrizQuaBol">     Yusen Logistics Philippines, Inc.</a>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a id="forAdmin" runat="server" href="#" style="color:white;font-family:Calibri">Admin controls</a></li>
<li><a id="forAdmin2" runat="server" href="#" style="color:white;font-family:Calibri">Maintenance</a></li>
<%--<li><a href="Requests.aspx" style="color:white">Requests</a></li>--%>
<li><a href="MyRequests.aspx" style="font-family:Calibri; color:white">My Requests</a></li>
<li class="dropdown">
<a id="admins" class="dropdown-toggle" data-toggle="dropdown" runat="server" style="color:white; font-family:Calibri; cursor:pointer">Requests <%--(<asp:Label ID="lblcount" runat="server" Text="#"></asp:Label>)--%></a>
<ul class ="dropdown-menu">
<li><a id="app1" runat="server" href="/MOSEF/PendingRequests.aspx" style="font-family:Calibri">Pending Requests <%--(<asp:Label ID="lblPending" runat="server" Text="#"></asp:Label>)--%></a></li>
<li><a id="app2" runat="server" href="/MOSEF/ApprovedRequests.aspx" style="font-family:Calibri">Approved Requests <%--(<asp:Label ID="lblApprove" runat="server" Text="#"></asp:Label>)--%></a></li>
<li><a id="app3" runat="server" href="/MOSEF/NotedRequests.aspx" style="font-family:Calibri">Noted Requests <%--(<asp:Label ID="lblApprove" runat="server" Text="#"></asp:Label>)--%></a></li>
<li><a id="app4" runat="server" href="/MOSEF/PendingHistory.aspx" style="font-family:Calibri">History <%--(<asp:Label ID="lblApprove" runat="server" Text="#"></asp:Label>)--%></a></li>
<%--<li><a href="#" style="font-family:Calibri">Accepted Requests (<asp:Label ID="lblAccept" runat="server" Text="#"></asp:Label>)</a></li>--%>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><asp:Label ID="lblName" runat="server" CssClass="control-label" Text="#" Visible="false"></asp:Label></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a id ="lblnames" class="dropdown-toggle" data-toggle="dropdown" runat="server" style="color:white; cursor:pointer">#</a>
<ul class ="dropdown-menu">
<li><a href="Account/Manage.aspx" style="font-family:Calibri">Manage Account</a></li>
<li><a id="endsession" href="../Account/LogInNoMaster.aspx" style="font-family:Calibri">Log Out</a></li>
</ul>
</li>
<%--<li><a runat="server" href="~/Account/Manage" title="Manage your account">Hello, <%: Context.User.Identity.GetUserName() %> !</a></li>
<li>
<asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" />
</li>--%>
</ul>
</div>
Session.Abandon()
Response.Redirect("default.aspx")
在你的html中添加一些类似的代码
<li><a id="app5" runat="server" href="/MOSEF/your_new_page.aspx" style="font-family:Calibri">Logout</a></li>
您可以使用这样的东西:
protected void Unnamed_LoggingOut(object sender, EventArgs e)
{
FormsAuthentication.SignOut();
Session.Abandon();
}