如何使用命令成员身份登录用户?

How do I login the user with commands membership?

我希望用户使用会员资格登录我的网站system.I使用此命令验证用户名和密码,然后登录用户。

Membership.ValidateUser("hmahdavi", "123456789");
        Membership.GetUser();

此代码无法正常工作。 请帮忙。

您做对了,但没有设置表单身份验证 cookie。只需设置身份验证 cookie。

       if (Membership.ValidateUser("hmahdavi", "123456789"))
        {
            FormsAuthentication.SetAuthCookie("hmahdavi", true);
            Response.Write("Logged in!");
        }