相关疑难解决方法(0)

表单身份验证了解context.user.identity

由于此过程的文档非常模糊且令人困惑(或过时),我想验证我是否正确执行并且没有遗漏任何步骤.

我正在尝试创建一个安全的登录系统,在浏览器关闭时到期.

- 在我的web.config中我有以下内容 -

<authentication mode="Forms">
      <forms loginUrl="~/Login.aspx" defaultUrl="Index.aspx" name=".ASPXFORMSAUTH" timeout="100" />
    </authentication>
    <authorization>
      <allow users="?" />
    </authorization>
    <machineKey decryption="AES" validation="SHA1" validationKey.......... />
Run Code Online (Sandbox Code Playgroud)

所以我有一个带有用户名/密码文本框的登录表单和这个按钮:

<asp:Button ID="LoginButton" runat="Server" OnClick="Login_Authenticate" Text="Sign in" />
Run Code Online (Sandbox Code Playgroud)

在Login_Authenticate内部我执行以下操作:

protected void Login_Authenticate(object sender, EventArgs e){
string userName = UserName.Text;
string password = Password.Text;

bool Authenticated = false;

// Here's code that makes sure that Username and Password is CORRECT
if(AuthClass.Authenticate(userName, password)){
 Authenticated = true;
}
// error checking does happen here.

if (Authenticated)
{
  FormsAuthenticationTicket ticket …
Run Code Online (Sandbox Code Playgroud)

c# asp.net forms-authentication

18
推荐指数
2
解决办法
7万
查看次数

标签 统计

asp.net ×1

c# ×1

forms-authentication ×1