Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to log out of the system and clear Cookie by ASP.NET

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to log out of the system and clear Cookie by ASP.NET". The editor shows you the operation process through an actual case. The method of operation is simple, fast and practical. I hope that this article "how to log out of the system and clear Cookie in ASP.NET" can help you solve the problem.

1. Front-end page code:

The front-end page code mainly displays the visual button code for exiting the system or website. The code is as follows: (please ignore the project keyword: CPU)

@ CPU.UserProfile.User.UserID @ using (Html.BeginForm ("LogOff", "Account", FormMethod.Post, new {id = "logoutForm", style = "padding: 12px 0px" "}) {@ Html.AntiForgeryToken () Log Out} Number of people online: @ System.Web.HttpContext.Current.Application ["OnLineUserCount"] 2. Background logic processing code:

The background code is mainly used to deal with the events when the foreground clicks the button: exit the system and clear the system Cookie

[HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public ActionResult LogOff () {FormsAuthentication.SignOut (); / exit login System.Web.HttpContext.Current.Session.Abandon (); / / clear cache return RedirectToAction ("Login", "Account");} 3. Interface effect:

This is the end of the introduction on "how ASP.NET logs out of the system and clears Cookie". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report