这是用户登陆的代码:
bool bvalid = Users.Login(username.Text, Users.Encrypt(password.Text));
if (bvalid) 
{
         // Use security system to set the UserID within a client-side Cookie
FormsAuthentication.SetAuthCookie(username.Text, false);
Session["userID"] = username.Text;
// Redirect browser back to originating page
Response.Redirect("Default.aspx");
}
web.config设置如下:
<authentication mode="Forms">
        <forms name="WebAuth" loginUrl="Default.aspx" protection="None" timeout="60" />
</authentication>我想用if (Request.IsAuthenticated == true)判断用户是否登陆, 怎么判断不了啊?

解决方案 »

  1.   

    你就if(Session["userID"] != null)好了
      

  2.   

    跟楼上的一样,判断一下Session中userID变量是不是为空就可以了
      

  3.   

    Form验证哪,你登陆之后有没有生成身份票号?
      

  4.   

    if(Session["userID"] == null||Session["userID"].Trim().ToString()=="")说明没有进入
      

  5.   

    Session["userID"] = null时楼上的会报错啊就if(Session["userID"] != null)好了
      

  6.   

    我弄不明白票号的生成结果,虽然判断session是可以的
      

  7.   

    楼主, 你这样能实现吗, Session是这样用的吗? ?把我给搞糊涂了....