2010-04-02 57 views
1

我有2页:Login.aspx和Satis.aspx。如果身份验证正确,我将从Login.aspx重定向到Satis.aspx。如果我从满意登出我重定向到Login.aspx。但是,如果我在web扫描器上编写satis.aspx'url,则输入satis.aspx。但是我没有登录Satis.aspx。我不应直接输入Satis.aspx。基于表单的身份验证问题?

我的web配置:

<authentication mode="Forms"> 
      <forms loginUrl="Login.aspx" name=".ASPXFORMSAUTH" path="/" protection="All"> 
       <credentials> 
        <user name="a" password="a"></user> 
       </credentials> 
      </forms> 
     </authentication> 

    <authorization> 
     <allow users="*"/> 
    </authorization> 


    </system.web> 
    <location path="~/ContentPages/Satis/Satis.aspx"> 
     <system.web> 
      <authorization> 
       <deny users="?"/> 
      </authorization> 
     </system.web> 
    </location>

Login.aspx.cs:

protected void lnkSubmit_Click(object sender, EventArgs e) 
     { 

      if(FormsAuthentication.Authenticate(UserEmail.Value,UserPass.Value)) 
      { 
        FormsAuthentication.RedirectFromLoginPage 
        (UserEmail.Value, PersistForms.Checked); 
      } 

      else 
       Msg.Text = "Invalid Credentials: Please try again"; 

     }

Satis.aspx

protected void LogoutSystem_Click(object sender, EventArgs e) 
     { 
      FormsAuthentication.SignOut(); 

      Response.Redirect("~/Login/Login.aspx"); 
     }
+0

你知道它的用户? – programmerist 2010-04-02 07:55:56

+0

请更改您的问题 – Midhat 2010-04-02 07:56:02

+0

您的意思是“换句话”是什么意思? – programmerist 2010-04-02 08:01:28

回答

3

我认为你应该使用“拒绝用户=“?”“而不是”allow users =“* “”在你的web.config文件

[*]指谁没有通过认证

[?]所有的用户即使是那些只意味着谁通过认证

+0

如果您不能为Login.aspx写这些 。我写了Satis.aspx – programmerist 2010-04-02 08:38:20

+0

我的问题。不清楚? – programmerist 2010-04-02 11:41:04

+0

不知道我有你的问题。如果你不想把这些改变放在配置文件中,你可以在你的Satis.aspx页面中使用“if(!Request.IsAuthenticated)Response.Redirect(”Login.aspx“); – 2010-04-02 11:47:47