[转][ASP.net]后台页面刷新

三种后台刷新页面的方法:

// 刷新方法一
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>

 更详细的文章:点此进入

posted on 2016-03-11 22:22  z5337  阅读(3467)  评论(0编辑  收藏  举报