我有一个 asp.net 登录页面。为了安全起见,我想清除缓存。但我不知道我应该把代码放在哪里。
感谢您提供代码片段建议。
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
bool UserAuthenticated = false;
MembershipProvider AuthenticationProviderUsed = null;
RoleProvider roleProvider = Roles.Providers["SqlRoleProvider"];
// Try authenticating the user against each membership provider
foreach (MembershipProvider membershipProvider in Membership.Providers)
{
try
{
...
Page.Session.Add("workspriv", access_value);
}
if (UserAuthenticated)
{
Response.Redirect("~/Search.aspx");
}
}
protected void Page_Load(object sender, EventArgs e)
{
lblDisclaimerText.Text = AntiXss.HtmlEncode(ConfigurationManager.AppSettings["DisclaimerText"]);
if (!IsPostBack)
{
if (Request.QueryString["Action"] != null && Request.QueryString["Action"].ToLower() == "logout")
{
Session.Abandon();
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
}
}
}