日期:2014-05-17  浏览次数:20614 次

方便判断是否登录的方法
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>