验证继承System.Security.Principal.IPrincipal 接口和System.Security.Principal.IIdentity接口
。这些都正常,正常登陆后跳到成功页,在login.aspx中在成功登陆后取Context.User.Identity.IsAuthenticated的值为True。除了这页。其它页的值匀为false.也就是登陆后只能在本页起作用。在别的页都是没有验证过的。这是Login.aspx.cs的代码。登陆成功后跳转我在此页登陆成功后输出if (Context.User.Identity.IsAuthenticated)
   {
Response.Write(Context.User.Identity.Name);Response.End();
}
这样能得到值。我在登陆成功页Default.aspx中无法取到值。Context.User.Identity.IsAuthenticated的值为false我是参照Asp.Net web站点高级编程做的。ThePhile哪位知道帮偶看看。困惑了好久.
     private void Submit_Click(object sender, System.EventArgs e)  
{   
   PhilePrincipal newUser = PhilePrincipal.ValidateLogin( EmailAddress.Text, Password.Text );           
    if (newUser == null)  
 {  
  LoginResult.Text = "Login failed for " + EmailAddress.Text;    LoginResult.Visible = true; 
  }  
 else   
 {    Context.User = newUser;    FormsAuthentication.SetAuthCookie( EmailAddress.Text, true );     
       Response.Redirect("/default.aspx");  
 }  
}

解决方案 »

  1.   

    注意PageBase中的此段代码: if (Context.User.Identity.IsAuthenticated) 
    {
    if (!(Context.User is SitePrincipal))
    {
    // ASP.NET's regular forms authentication picked up our cookie, but we
    // haven't replaced the default context user with our own. Let's do that
    // now. We know that the previous context.user.identity.name is the e-mail
    // address (because we forced it to be as such in the login.aspx page)
    SitePrincipal newUser = new SitePrincipal( Context.User.Identity.Name );
    Context.User = newUser;
    }
    }
      

  2.   

    这里我的加上了。而且也在每页继承了PageBase。
    但就只是在login.aspx页面里可以读验证过的信息
    PageBase重写了页面载入。的这些我都加上了,还是一样。哎!
    并且我也验证了PageBase_load里的东东确实执行了。但执行到验证是否通过时
    还是没有通过。!@
      

  3.   

    检查:
    Identity
    Principal
      

  4.   

    FormsAuthentication.SetAuthCookie 方法
    创建身份验证票并将其附加到 Cookie 的传出响应的集合。它不执行重定向
    不知道此方法key的值是按什么来创建的
    好像是按工程名或者虚拟目录的名称创建建的
    Thephile的用此方法后Cookie的key的值值为Thephile
    而我建的如果是根目录的话key值为.aspxauth
    如果是虚拟目录的话
    我的工程得到的key的值却不为虚拟目录的名称
    可能是这里不同吧。但我也不知道该改哪里。
      

  5.   

    web.config
    里没有采用Forms认证。晕!
    原来是这个。我记得改过来的1