当前位置: 代码迷 >> ASP.NET >> 便利判断是否登录的方法
  详细解决方案

便利判断是否登录的方法

热度:5276   发布时间:2013-02-25 00:00:00.0
方便判断是否登录的方法
asp.net 中有没有类似jAVA中的include的指令,或者是web.config配置文件呢?用于判断用户是否登录。用判断session太麻烦了。谢谢

------解决方案--------------------------------------------------------
用form认证!
直接在webconfig中加入
C# code
<authentication mode="Forms">      <forms loginUrl="~/Login.aspx" name=".ASPXFORMSAUTH" enableCrossAppRedirects="true">      </forms>    </authentication>    <authorization>      <deny users="?" />    </authorization>
------解决方案--------------------------------------------------------
web.config 的location节点可以限制是否已经登录过的
------解决方案--------------------------------------------------------
iframe嵌套页面判断
basepage判断sesson
forms验证
public class BasePage : System.Web.UI.Page
{
public BasePage()
{ }
protected override void OnInit(EventArgs O)
{
if (base.Session["UserId"] == null || base.Session["UserId"].ToString().Equals(""))
{
Response.Redirect("~/Error.aspx");
}
}

}
<authentication mode="Forms">
<forms loginUrl="/login.aspx" defaultUrl="~/a.aspx" />
</authentication>

  相关解决方案