三種后台刷新頁面的方法:
// 刷新方法一 Response.AddHeader("Refresh", "0"); // 刷新方法二 Response.Write("<script language=javascript>window.location.href=document.URL;</script>"); // 刷新方法三 Response.Redirect(Request.Url.ToString());
ASP.net Form 身份驗證
// 添加身份 FormsAuthentication.SetAuthCookie(loginName, true); // 注銷 FormsAuthentication.SignOut();
前台獲取登錄信息
// 登錄信息 <%= Context.User.Identity.Name %> // 是否登錄 Request.IsAuthenticated
相應的 web.config
<!-- 通過 <authentication> 節可以配置 ASP.NET 使用的 安全身份驗證模式, 以標識傳入的用戶。 --> <authentication mode="Forms"> <forms cookieless="UseCookies" name="LoginCookieName" loginUrl="~/WebMain.aspx"></forms> </authentication> <authorization> <!-- 禁用所有 --> <deny users="*"/> <!-- 允許所有 --> <allow users="*"/> </authorization>
更詳細的文章:點此進入